ggplot2
ggplot2 copied to clipboard
Feature request: nicer error message for coord_cartesian
I would like coord_cartesian
to return a more human-readable error when I mess up the syntax:
example
library(ggplot2)
ggplot(iris, aes(Petal.Length,Petal.Width)) +
geom_point() +
coord_cartesian(xlim(2,6))
observed behaviour
Error in rep(no, length.out = len) :
attempt to replicate an object of type 'environment'
In addition: Warning message:
In is.na(coord_limits) :
is.na() applied to non-(list or vector) of type 'environment'
expected behaviour
Error in coord_cartesian: did you mean "xlim = c()"?
Reprex:
library(ggplot2)
ggplot(iris, aes(Petal.Length,Petal.Width)) +
geom_point() +
coord_cartesian(xlim(2,6))
#> Warning in is.na(coord_limits): is.na() applied to non-(list or vector) of type
#> 'environment'
#> Error in rep(no, length.out = len): attempt to replicate an object of type 'environment'
Created on 2022-04-19 by the reprex package (v2.0.1)
Just needs a little type checking in coord_cartesian()
.
Considered completed by #4894.