Closed
Description
I added limits = c(1, 2, 3)
to a scale_* and I didn't realize it (I though I used breaks
). But was surprised by the resulting plot: it only uses the two first values and discards the rest (Totally logic and consistent).
But the documentation says:
A numeric vector of length two providing limits of the scale. Use NA to refer to the existing minimum or maximum
I would like to receive an error if the vector used in limits for scales is larger than 2. This would help to fail with an informative error. I got a warning of Removed <x> rows containing missing values or values outside the scale range
:
library("ggplot2")
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(limits = c(1, 5, 10))
## Warning message:
## Removed 36 rows containing missing values or values outside the scale range (`geom_point()`).
Expected:
library("ggplot2")
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(limits = c(1, 5, 10))
## Error in scale_x_continuous:
## Provided limits for three dimensions when only two are used.
This might happen to other limits from other scale_* functions or in other arguments