8 Chart: Ridgeline Plots

This chapter originated as a community contribution created by nehasaraf1994

This page is a work in progress. We appreciate any input you may have. If you would like to help improve this page, consider contributing to our repo.

8.1 Overview

This section covers how to make ridgeline plots.

8.3 Simple examples

Okay…much simpler please.

Let’s use the Orange dataset from the datasets package:

## Grouped Data: circumference ~ age | Tree
##   Tree  age circumference
## 1    1  118            30
## 2    1  484            58
## 3    1  664            87
## 4    1 1004           115
## 5    1 1231           120

8.5 When to Use

Ridgeline plots can be used when a number of data segments have to be plotted on the same horizontal scale. It is presented with slight overlap. Ridgeline plots are very useful to visualize the distribution of a categorical variable over time or space.

A good example using ridgeline plots will be a great example is visualizing the distribution of salary over different departments in a company.

8.6 Considerations

The overlapping of the density plot can be controlled by adjusting the value of scale. Scale defines how much the peak of the lower curve touches the curve above.

Ridgeline plots can also be used to plot histograms on the common horizontal axis rather than density plots. But doing that may not give us any valuable results.

If the same thing is done in ridgeline plots, it gives better results.

8.7 External Resources

  • Introduction to ggridges: An excellent collection of code examples on how to make ridgeline plots with ggplot2. Covers every parameter of ggridges and how to modify them for better visualization. If you want a ridgeline plot to look a certain way, this article will help.

  • Article on ridgeline plots with ggplot2: Few examples using different examples. Great for starting with ridgeline plots.

  • History of Ridgeline plots: To refer to the theory of ridgeline plots.