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
Milestone

Comments

@jasonelaw
Copy link

@jasonelaw jasonelaw commented Apr 2, 2013

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 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?

Loading

@hadley
Copy link
Member

@hadley 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.

Loading

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

@johnaponte johnaponte commented Oct 23, 2015

I have the same problem if the y values are Inf

Loading

@drolejoel
Copy link

@drolejoel drolejoel commented Dec 23, 2015

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.

Loading

@Inventitech
Copy link

@Inventitech Inventitech commented Apr 28, 2016

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.

Loading

@mattbk
Copy link

@mattbk mattbk commented Oct 6, 2016

all your input data is NA

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

Loading

@hadley hadley reopened this Oct 6, 2016
@hadley hadley added the bug label Oct 6, 2016
@hadley hadley added this to the v2.2.0 milestone Oct 6, 2016
@hadley hadley closed this in c8dec1e Oct 6, 2016
@hadley
Copy link
Member

@hadley hadley commented Oct 6, 2016

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

Loading

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants