wilkelab / ggridges

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

Issue with `check_required_aesthetics()` - y not found #73

Open LukasWallrich opened 2 years ago

LukasWallrich commented 2 years ago

Thanks for this great package & please note that I have not encountered this issue in production but just when playing around - but I still wanted to report it just in case it matters.

In the code below, I get an error message claiming that the y-aesthetic is missing, while it is clearly provided and also picked up by other geoms.

library(ggridges)
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = cyl)) + geom_density_ridges()
#> Picking joint bandwidth of 2.48
#> Error in `check_required_aesthetics()`:
#> ! geom_density_ridges requires the following missing aesthetics: y
clauswilke commented 2 years ago

Not sure why the error message is what it is. The problem is that the y aesthetic needs to be discrete.

library(ggridges)
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = factor(cyl))) + 
  geom_density_ridges()
#> Picking joint bandwidth of 1.38

Created on 2022-02-09 by the reprex package (v2.0.0)

LukasWallrich commented 2 years ago

So simple - but not something I would have figured out anytime soon from that error ...