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

Merged
merged 13 commits into from
Oct 30, 2024
Merged

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

R/stat-qq-line.R Outdated Show resolved Hide resolved
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from small comment LGTM

@teunbrand teunbrand merged commit 8a4c25a into tidyverse:main Oct 30, 2024
13 checks passed
@teunbrand teunbrand deleted the check_scale_limits branch October 30, 2024 10:04
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
2 participants