ggridges

star 5

R ggridges package for ridgeline plots. Use for creating ridgeline/joy plots showing distributions.

LeoLin990405 By LeoLin990405 schedule Updated 1/30/2026

name: ggridges description: R ggridges package for ridgeline plots. Use for creating ridgeline/joy plots showing distributions.

ggridges

Ridgeline plots in ggplot2.

Basic Ridgeline

library(ggplot2)
library(ggridges)

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges()

With Fill

ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
  geom_density_ridges() +
  theme_ridges() +
  theme(legend.position = "none")

Gradient Fill

ggplot(diamonds, aes(x = price, y = cut, fill = stat(x))) +
  geom_density_ridges_gradient() +
  scale_fill_viridis_c(option = "C")

Quantile Lines

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(
    quantile_lines = TRUE,
    quantiles = c(0.25, 0.5, 0.75)
  )

Jittered Points

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(
    jittered_points = TRUE,
    point_size = 0.5,
    point_alpha = 0.3
  )

Raincloud Plots

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(
    jittered_points = TRUE,
    position = position_points_jitter(width = 0.05, height = 0),
    point_shape = '|',
    point_size = 3,
    alpha = 0.7
  )

Histogram Ridges

ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
  geom_density_ridges(stat = "binline", bins = 30) +
  theme_ridges()

Scale and Overlap

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(
    scale = 2,      # Overlap amount
    rel_min_height = 0.01  # Cut off tails
  )

Bandwidth

ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(bandwidth = 500)

Theme

# Built-in theme
ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges() +
  theme_ridges(grid = FALSE, center_axis_labels = TRUE)
Install via CLI
npx skills add https://github.com/LeoLin990405/r-analytics-skill --skill ggridges
Repository Details
star Stars 5
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator
LeoLin990405
LeoLin990405 Explore all skills →