Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check continuous scale limits #6114

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6092, but has escalated a bit.

I'd say the main thing is that this PR adds and uses a check_length() function that checks whether the length of a vector is of a particular length or within a range of lengths.
This is then used to check scale limits and replace ad hoc length checks.

Small demo:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
scale_x_continuous(limits = c("A", "B"))
#> Error in `scale_x_continuous()`:
#> ! `limits` must be a <numeric> vector, not a character vector.
scale_x_continuous(limits = c(1:3))
#> Error in `scale_x_continuous()`:
#> ! `limits` must be a vector of length 2, not length 3.

Created on 2024-09-17 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checking limits argument in scale_<x|y>_continuous
1 participant