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

Feature request: nicer error message for coord_cartesian #4601

Closed
petyaracz opened this issue Sep 2, 2021 · 2 comments
Closed

Feature request: nicer error message for coord_cartesian #4601

petyaracz opened this issue Sep 2, 2021 · 2 comments
Labels
coord 🗺️ help wanted ❤️ we'd love your help! messages requests for improvements to error, warning, or feedback messages

Comments

@petyaracz
Copy link

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()"?
@thomasp85 thomasp85 added the messages requests for improvements to error, warning, or feedback messages label Oct 28, 2021
@hadley
Copy link
Member

hadley commented Apr 19, 2022

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().

@teunbrand
Copy link
Collaborator

Considered completed by #4894.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coord 🗺️ help wanted ❤️ we'd love your help! messages requests for improvements to error, warning, or feedback messages
Projects
None yet
Development

No branches or pull requests

4 participants