Skip to content

coord_cartesian() should probably throw an error is xlim or ylim is length 1 #5297

@DavisVaughan

Description

@DavisVaughan

I accidentally ran this, and was rather confused for awhile until I realized I hadn't supplied an upper limit in xlim:

library(ggplot2)

df <- data.frame(
  x = 1:5,
  y = 2:6
)

ggplot(df, aes(x, y)) +
  geom_line() +
  coord_cartesian(xlim = 2)
#> Error in if (all(is.finite(continuous_range_coord)) && diff(continuous_range_coord) < : missing value where TRUE/FALSE needed

Could coord_cartesian(), or possibly something later on, throw an error if it doesn't get a length 2 xlim / ylim?

Metadata

Metadata

Assignees

No one assigned

    Labels

    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