Skip to content

Feature request: nicer error message for coord_cartesian #4601

@petyaracz

Description

@petyaracz

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()"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    coord 🗺️help wanted ❤️we'd love your help!messagesrequests for improvements to error, warning, or feedback messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions