error message complains about missing aesthetic that is not missing
Closed this issue · 6 comments
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.
>
Please provide a minimal and complete reproducible example, preferably prepared with the reprex package.
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))
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)
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.
It's a ggplot2 issue. I've reported it there.
tidyverse/ggplot2#3901
Thank you.