Learn R Programming

⚠️There's a newer version (0.5.6) of this package.Take me there.

ggridges: Ridgeline plots in ggplot2

Ridgeline plots are partially overlapping line plots that create the impression of a mountain range. They can be quite useful for visualizing changes in distributions over time or space.

Installation

Please install the stable release from CRAN:

install.packages("ggridges")

Alternatively, you can install the latest development version from github:

remotes::install_github("wilkelab/ggridges")

Usage

library(ggplot2)
library(ggridges)
    
ggplot(diamonds, aes(x = price, y = cut)) +
  geom_density_ridges(scale = 4) + 
  scale_y_discrete(expand = c(0, 0)) +     # will generally have to set the `expand` option
  scale_x_continuous(expand = c(0, 0)) +   # for both axes to remove unneeded padding
  coord_cartesian(clip = "off") + # to avoid clipping of the very top of the top ridgeline
  theme_ridges()
#> Picking joint bandwidth of 458

Documentation and Examples

First read the package vignette. Then read the reference manual.

Copy Link

Version

Install

install.packages('ggridges')

Monthly Downloads

90,443

Version

0.5.3

License

GPL-2 | file LICENSE

Maintainer

Last Published

January 8th, 2021

Functions in ggridges (0.5.3)

geom_density_line

Smoothed density estimates drawn with a ridgeline rather than area
ggridges

Ridgeline plots with ggplot2
geom_vridgeline

Plot a vertical ridgeline (ridgeline rotated 90 degrees)
lincoln_weather

Weather in Lincoln, Nebraska in 2016.
Aus_athletes

Australian athletes
geom_ridgeline_gradient

Plot ridgelines and ridgeline plots with fill gradients along the x axis
geom_density_ridges

Create ridgeline plot
Catalan_elections

Results from Catalan regional elections (1980-2015)
geom_ridgeline

Plot a ridgeline (line with filled area underneath)
position_points_jitter

Randomly jitter the points in a ridgeline plot
theme_ridges

A custom theme specifically for use with ridgeline plots
stat_binline

Stat for histogram ridgeline plots
position_points_sina

Randomly distribute points in a ridgeline plot between baseline and ridgeline
scale_vline

Scales for vline aesthetics
scale_point

Scales for point aesthetics
stat_density_ridges

Stat for density ridgeline plots
position_raincloud

Create a cloud of randomly jittered points below a ridgeline plot
scale_cyclical

Create a discrete scale that cycles between values
reduce

Reduce a list to a single value by iteratively applying a binary function