For questions about creating a Ridgeline plot, sometimes called a Joyplot. When using this tag also tag the language you are coding in for context. Where applicable please also tag any third party package(s) you are using for context.
Questions tagged [ridgeline-plot]
78 questions
19
votes
6 answers
geom_density_ridges requires the following missing aesthetics: y
No matter what I try I cannot create a ridgeline plot using ggridges. Using a dataframe graphing_dataframe that looks as follows:
str(graphing_dataframe)
summary(graphing_dataframe)
> str(graphing_dataframe)
Classes ‘tbl_df’, ‘tbl’ and…

Frank B.
- 1,813
- 5
- 24
- 44
13
votes
2 answers
Stop geom_density_ridges from showing non-existent tail values
When I use geom_density_ridges(), the plot often ends up showing long tails of values that don't exist in the data.
Here's an example:
library(tidyverse)
library(ggridges)
data("lincoln_weather")
# Remove all negative values for "Minimum…

John J.
- 1,450
- 1
- 13
- 28
11
votes
1 answer
How can I add a vertical colour gradient to a ridgeplot in ggridges?
The ggridges package lets you draw ridgeplots with either solid colour:
ggplot(iris, aes(x=Sepal.Width, y=Species))+
geom_density_ridges(alpha=0.33, scale=2, fill="#0570b0", colour=alpha(0.1))+
theme_classic()
or with horizontal colour…

VictimOfMaths
- 179
- 7
7
votes
1 answer
How to adjust bandwidth for ridgeplots in R
When using the geom_density_ridges function in the ggridges package, it always picks a bandwidth for all the densities in the plot. But is there a way to adjust the bandwidth that it chooses?
I currently have some code to make a ridge plot, but the…

user-2147482565
- 453
- 7
- 16
6
votes
1 answer
Flipping Axes of ggplot
My dataframe looks like this:
df <- data.frame(label=c("yahoo","google","yahoo","yahoo","google","google","yahoo","yahoo"), year=c(2000,2001,2000,2001,2003,2003,2003,2003))
How is it possible to produce a thermal plot like this…

Elr Mant
- 507
- 1
- 4
- 14
6
votes
2 answers
Line at the top of a ridgeline density plot is cut off
Why is the top of the plot cut off and how do I fix this? I've increased the margins and it made no difference.
See the curve for year 1854, at the very top of the left hump. It appears the line is thinner at the top of the hump. For me, changing…

ixodid
- 2,180
- 1
- 19
- 46
6
votes
1 answer
Add custom vertical line joyplots ggridges
I would like to add a vertical line by row to joy plots using ggridges.
# toy example
ggplot(iris, aes(x=Sepal.Length, y=Species, fill=..x..)) +
geom_density_ridges_gradient(jittered_points = FALSE, quantile_lines =
FALSE, quantiles = 2, scale=0.9,…

sdaza
- 1,032
- 13
- 29
5
votes
1 answer
Adding a mean to geom_density_ridges
I am trying to add means using geom_segment to a geom_density_ridges plot made in ggplot2.
library(dplyr)
library(ggplot2)
library(ggridges)
Fig1 <- ggplot(Figure3Data, aes(x = `hairchange`, y = `EffortGroup`)) +
…

jbearazesh
- 101
- 1
- 6
4
votes
2 answers
Ridge plot: sort by value / rank
I have a data set which I uploaded here as a gist in CSV format.
It is the extracted form of the PDFs provided in the YouGov article "How good is 'good'?". People where asked to rate words (e.g. "perfect", "bad") with a score between 0 (very…

Thomas
- 1,199
- 1
- 14
- 29
4
votes
2 answers
Cyclical Error using ggridges in R (joyplot)
I am currently working with the ggridges library, in order to make a 'joychart.' I wrote this:
data3 %>%
mutate(ftFct = fct_rev(as.factor(ft_newnum))) %>%
ggplot(aes(y = ftFct)) +
geom_density_ridges(aes(x = ft, fill = paste(ftFct, rep)),
…

Oliver G
- 1,021
- 2
- 9
- 20
4
votes
1 answer
How to reproduce this moving distribution plot with R?
G Elliot Moris showed political polarization through time using a moving distribution plot.
From this question: How to use 'facet' to create multiple density plot in GGPLOT, I managed to use facets to reproduce a similar plot using dummy…

Paul Rougieux
- 10,289
- 4
- 68
- 110
3
votes
1 answer
Altair Ridgeline doesn't create a plot with nominal groups
I try to create a Ridgeline plot in altair. Let's assume my dataframe consists of str and float columns:
a object
b float64
dtype: object
with values like
a b
0 25 2303.0
1 29 2676.0
2 18 2983.0
3 16 1489.0
4 21 3468.0
I…

maria
- 494
- 4
- 13
3
votes
2 answers
Using base R, how to create a "joy plot" (aka ridgeline plots), with many distributions on top of each other with vertical offset?
The type of plot I am trying to achieve in R seems to have been known as either as moving distribution, as joy plot or as ridgeline plot:
There is already a question in Stackoverflow whose recorded answer explains how to do it using ggplot: How to…

ZXiu
- 33
- 2
3
votes
1 answer
Reordering a factor based on a summary statistic of a subset of the data
I'm trying to reorder a factor from a subset of my data frame, defined by another factor using forcats::fct_reorder().
Consider the following data frame df:
set.seed(12)
df <- data.frame(fct1 = as.factor(rep(c("A", "B", 'C'), each = 200)),
…

PRZ
- 551
- 2
- 11
3
votes
2 answers
Reorder panels in ridgeline plot
I have a dataframe like this:
set.seed(3467)
df<- data.frame(method= c(rep("A", 1000), rep("B", 1000), rep("C", 1000)),
beta=c(rnorm(1000, mean=0, sd=1),rnorm(1000, mean=2, sd=1.4),rnorm(1000, mean=0, sd=0.5)))
I wish to create a…

Danielle
- 785
- 7
- 15