ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Check continuous scale limits

Open teunbrand opened this issue 1 year ago • 0 comments

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

teunbrand avatar Sep 17 '24 15:09 teunbrand