Okay folks how alive is the #rstats #dataviz crowd here? I want to create ridgeline plots with ggridges::geom_density_ridges, but with the trim=T option of ggplot::geom_density. There's an open feature request at wilkelab/ggridges#57 so I don't think @clauswilke has been able to implement this
Interested in ideas! Main reason to want ridges instead of vanilla density plots is multifaceted data — see example plot.
https://scholar.social/@dingemansemark/109659218719054960
This can be done nicely with ggdist. See this article in the documentation for more info: https://mjskay.github.io/ggdist/articles/slabinterval.html#creating-ridge-plots
library(ggplot2)
library(ggdist)
set.seed(126)
group_n <- 30
facet_df <- data.frame(
group = rep(rep(rep(letters[1:3], 3), each = group_n), each = 2),
facet = rep(letters[1:2], group_n * 3),
x = rep(rep(c(
rnorm(group_n, 0, 0.25),
rbeta(group_n, 1, 5, 4),
rbeta(group_n, 1, 5, 4)
), 3), each = 2)
)
ggplot(facet_df, aes(x = x, y = group)) +
stat_slab(height = 2, colour = "black") +
facet_wrap(vars(facet))
Created on 2023-01-09 with reprex v2.0.2