Skip to content

Better error message for plots (or facets with free scales) with all missing values. #791

Closed
@jasonelaw

Description

@jasonelaw

This bit me in a large,faceted plot where it wasn't entirely obvious what was going on:

d <- data.frame(x = 1:5, y = as.double(NA))
ggplot(data = d, aes(x, y)) + geom_point()
Error in seq.default(from = best$lmin, to = best$lmax, by = best$lstep) : 
  'from' must be of length 1

This is more like what caught me:

d <- expand.grid(x = 1:5, f = letters[1:5])
d$y <- rnorm(25)
is.na(d$y) <- d$f == 'a'
ggplot(data = d, aes(x, y)) + geom_point() + facet_wrap(~ f, scales = 'free_y')

Is it possible to catch this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions