library(ggplot2)
library(ggridges)
ggplot(iris, aes(x = Sepal.Width, y = Species, fill = Species))
geom_density_ridges(scale = 1.1, quantile_lines=TRUE,
quantile_fun=function(x,...)mean(x))
ggplot(iris, aes(x =Species , y = Sepal.Width, fill = Species, width=..density..))
geom_vridgeline(stat="ydensity", scale = 1.1)
Basically, I want to add lines like this:
to this:
quantile_lines=TRUE
does not work for geom_vridgeline()
. I would appreciate any assistance. Thank you!
CodePudding user response:
To create horizontal ridgelines, you can use geom_density_ridges() and modify the aesthetics mapping. You can use coord_flip() function to flip the x and y axis coordinates.
Try this code:
ggplot(iris, aes(x = Sepal.Width, y = Species, fill = Species))
geom_density_ridges(scale = 1.1, quantile_lines=TRUE,
quantile_fun=function(x,...)mean(x))
coord_flip()