position_raincloud: Create a cloud of randomly jittered points below a ridgeline...

View source: R/position.R

position_raincloudR Documentation

Create a cloud of randomly jittered points below a ridgeline plot

Description

This is a position adjustment specifically for geom_density_ridges() and related geoms. It only jitters the points drawn by these geoms, if any. If no points are present, the plot remains unchanged. The effect is similar to position_points_jitter(), only that by default the points lie all underneath the baseline of each individual ridgeline.

Usage

position_raincloud(
  width = 0,
  height = 0.4,
  ygap = 0.05,
  adjust_vlines = FALSE,
  seed = NULL
)

Arguments

width

Width for horizontal jittering. By default set to 0.

height

Total height of point cloud. By default 0.4.

ygap

Vertical gap between ridgeline baseline and point cloud.

adjust_vlines

If TRUE, adjusts vertical lines (as are drawn for quantile lines, for example) to align with the point cloud.

seed

Random seed. See position_points_jitter.

Details

The idea for this position adjustment comes from Micah Allen's work on raincloud plots (Allen et al. 2021).

References

Allen, M., Poggiali, D., Whitaker, K., Marshall, T. R., van Langen, J., Kievit, R. A. (2021) Raincloud plots: a multi-platform tool for robust data visualization [version 2; peer review: 2 approved]. Wellcome Open Res 4:63.

See Also

Other position adjustments for ridgeline plots: position_points_jitter, position_points_sina

Examples

library(ggplot2)

ggplot(iris, aes(x = Sepal.Length, y = Species)) +
  geom_density_ridges(jittered_points = TRUE, position = "raincloud", alpha = 0.7)

ggridges documentation built on May 29, 2024, 9:53 a.m.