Closed heinonmatti closed 6 years ago
That's fairly simple to implement in principle. My main concern is that the API is getting cluttered by introducing all these different parameter options in geom_density_ridges()
and geom_stat_ridges()
. Maybe I'd have to introduce a separate geom, e.g. geom_raincloud()
.
I realized that the correct way to implement this is via a position argument. Would you mind trying this out?
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(jittered_points = TRUE, position = "raincloud", alpha = 0.7)
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(jittered_points = TRUE, alpha = 0.7, scale = 0.8, point_size = 0.5,
position = position_raincloud(width = 0.05, height = 0.2))
Also, the same code has enabled other options, such as this one:
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(jittered_points = TRUE, alpha = 0.7, point_size = 3, point_shape = "|",
position = position_points_jitter(width = 0.05, height = 0))
This is really nice work (examples work for me)... and makes the package even more usable... Do you think a position = "boxplot"
would also be possible...?
Position adjustments can only move things around that are already drawable. To draw boxplots, I'd have to add that somehow to geom_ridgeline()
, and I'm hesitant to do so. The ggplot2 approach would be to have this in a separate geom, and that works already unless you want the density distributions to partially overlap with boxplots, which is not necessarily useful anyways.
However, we can position adjust the quantile lines. That's probably as far as I'm willing to go with adding extra drawing elements to the geom.
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
geom_density_ridges(jittered_points = TRUE, quantile_lines = TRUE, scale = 0.9, alpha = 0.7,
vline_size = 1, vline_color = "red", point_size = 0.4,
position = position_raincloud(adjust_vlines = TRUE))
Exactly what I needed, perfect, many thanks!
@modche, I used userfriendlyscience::diamondPlot with returnLayerOnly = TRUE and otherAxisCol = (1:4 - .25), to overlay separately calculated (my data is clustered, so vanilla ones won't do) means + confidence intervals on plot:
... actually, having the diamonds on the density plots might make more sense here:
Seems like the points get cut off by the x-axis in the lowest of the four plots?
If the axes are cut off you may have to expand them manually using the various avenues ggplot2 provides for this. Unfortunately ggplot2 sometimes gets the axis range wrong, the same can be observed at the very top of the top ridgeline. There's currently no way from within ggridges to fix this.
I think this issue is fully addressed now.
Hi,
I came across this: https://micahallen.org/2018/03/15/introducing-raincloud-plots/
Would it be possible to plot the points below the ridges, instead of inside them?
Many thanks for the great work,
Matti