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

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

Closed
jasonelaw opened this issue Apr 2, 2013 · 7 comments
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@jasonelaw
Copy link

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?

@ghost
Copy link

ghost commented Feb 4, 2014

I've encountered the same issue in a large dataset with faceted plots after melting the dataframe. Is there any workaround?

@hadley
Copy link
Member

hadley commented Feb 24, 2014

This sounds like a great feature/horrible bug, but unfortunately we don't currently have the development bandwidth to support it/fix it. If you'd like to submit a pull request that implements this feature/fixes this bug, please follow the instructions in the development vignette.

@hadley hadley closed this as completed Feb 24, 2014
@johnaponte
Copy link

I have the same problem if the y values are Inf

@drolejoel
Copy link

not sure if this helps but there is a workaround with ggplot2 v1.0.1 (see http://stackoverflow.com/questions/23593159): The solution for me was to make sure my data.frame was nice and clean, by removing all NA values from the column with the Y axis data.

@Inventitech
Copy link

I just ran into this problem having upgraded to ggplot 2.0 (which was unrelated, but I did not know that at that time) and it took me 15 mins to figure out what was actually wrong. Yeah, if you can, please provide a better error message that makes it easier to spot that, for example, all your input data is NA.

@mattbk
Copy link

mattbk commented Oct 6, 2016

all your input data is NA

Not just for x and y, but other aesthetics as well.

@hadley hadley reopened this Oct 6, 2016
@hadley hadley added the bug an unexpected problem or unintended behavior label Oct 6, 2016
@hadley hadley added this to the v2.2.0 milestone Oct 6, 2016
@hadley hadley closed this as completed in c8dec1e Oct 6, 2016
@hadley
Copy link
Member

hadley commented Oct 6, 2016

No one supplied any reprexes apart from the initial, but I think this is fixed now.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants