wilkelab / ggridges

Ridgeline plots in ggplot2
https://wilkelab.org/ggridges
GNU General Public License v2.0
411 stars 31 forks source link

error message complains about missing aesthetic that is not missing #56

Closed tsgouros closed 4 years ago

tsgouros commented 4 years ago

I can't see why it shouldn't be possible to use ggridge to plot a time series, but I cannot figure out how, and the error message I get is mysterious. The 'height' aesthetic is specified here, but the complaint is that it is not. This seems like an erroneous error message, so I'm reporting it. If someone can also tell me what I'm doing wrong, I'd be grateful, too.

> ggplot(Theoph, aes(x=Time, y=Subject, fill=Subject, height=conc)) +
+ geom_density_ridges() + theme_ridges() +
+ scale_y_discrete(expand=c(0.01,0)) + scale_x_continuous(expand=c(0.01,0)) 
Picking joint bandwidth of 3.02
Error: geom_density_ridges_gradient requires the following missing aesthetics: height
Run `rlang::last_error()` to see where the error occurred.
> 
clauswilke commented 4 years ago

Please provide a minimal and complete reproducible example, preferably prepared with the reprex package.

tsgouros commented 4 years ago

That is a minimal and complete example. Does it not work for you? Theoph is part of the R datasets package which I think is part of tidyverse. So how about this:

library(ggplot2)
library(ggridges)
library(tidyverse)

ggplot(Theoph, aes(x=Time, y=Subject, fill=Subject, height=conc)) +
    geom_density_ridges() + theme_ridges() +
    scale_y_discrete(expand=c(0.01,0)) + scale_x_continuous(expand=c(0.01,0))
clauswilke commented 4 years ago

Is this what you're trying to do?

library(ggridges)
library(tidyverse)

ggplot(Theoph, aes(x=Time, y=Subject, fill=Subject, height=conc)) +
  geom_density_ridges(stat = "identity") + theme_ridges() +
  scale_y_discrete(expand=c(0.01,0)) + scale_x_continuous(expand=c(0.01,0))

Created on 2020-03-19 by the reprex package (v0.3.0)

tsgouros commented 4 years ago

Well, yes it is, thank you. But I hope you won't mind my calling to your attention an error message that tells me that something is wrong that is clearly not wrong. Perhaps the message might be changed to something about requiring stat=identity?

Still, thank you for the assistance here.

clauswilke commented 4 years ago

It's a ggplot2 issue. I've reported it there. https://github.com/tidyverse/ggplot2/issues/3901

tsgouros commented 4 years ago

Thank you.