Questions tagged [ggridges]

The ggridges R package is an add-on package to ggplot2. It provides geoms, stats, themes, and scales useful for the creation of ridgeline plots.

Resources:

  1. Introduction to ggridges
  2. github project
102 questions
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
0 answers

mutliple variables in a 'ggridges' plot

I discovered this amazing R package ggridges and would like to use it for a graph, however, I am failing at executing the code, as I am probably wrongly putting my variables. I was hoping someone could guide me in obtaining the result I want. Please…
Jo-Achna
  • 315
  • 1
  • 3
  • 14
3
votes
0 answers

How to add a yaxis

So I've been trying to add Y axis on my histograms. Right now my Y scale is discrete but if i change it to continuous it does not plot. I would like for the code to have a y axis listing how many number of turtles. Please let me know what I can do,…
3
votes
0 answers

R ggridges: color geom_ridges_density_gradient based on a third variable

Does anyone know if the coloring in ggridges::geom_ridges_density_gradient can be controlled by a third variable? To explain, if I draw a ridge diagram of wind directions in Lincoln NE (modified from an example in…
stuttungr
  • 399
  • 1
  • 4
  • 12
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
3
votes
1 answer

How to add geom_point to stat_density_ridges

I am able to draw density_ridge using this code. I want to add geom_point at percentile 0.50 without changing the current design. Any help would be much appreciated. library(ggplot2) library(ggridges) ggplot(iris, aes(x=Sepal.Length, y=Species,…
Krantz
  • 1,424
  • 1
  • 12
  • 31
3
votes
1 answer

ggplot in r: duplicate faceted geom_density and geom_density_ridges results

The default settings for ggplot2::geom_density() with a facet and ggridges::geom_density_ridges() yield slightly different curves. How can I modify the smoothing technique in one or the other to yield the same…
Shannon Pileggi
  • 101
  • 1
  • 3
3
votes
1 answer

ggridges with heights scaled to counts

How do I change the scaling of a ggridges figure so that the plot behaves more like a histogram, and less like a kernel density plot? That is, I would like the figure to reflect the disparate size of the categorical variable. For…
tomw
  • 3,114
  • 4
  • 29
  • 51
3
votes
1 answer

Reverse order of breaks in ggplot, ggridges

I have a dataset with Length (integer) and Year (factor) that I want to plot using ggridges. Here is an analogous dataset with integer and factor data. How do I change the order of Species (i.e. factor) on the…
KVininska
  • 107
  • 1
  • 6
3
votes
1 answer

Disable Histogram Scaling in ggplot2 ggridges

Please have a look at the following histograms of temperature for the various months of the year. I limit the temperature to 50+ degrees to purposefully force some of the the histograms to be small, for the colder months. Make note of months 1, 2,…
stackinator
  • 5,429
  • 8
  • 43
  • 84
3
votes
1 answer

Using R ggridges (R-joyplot) for bar charts

Is it possible to use the ggridges package to draw sets of bars instead of ridgelines, similar to geom_col()? I have data such as: dt = tibble( hr = c(1,2,3,4,1,2,3,4), fr = c(.1,.5,.9,.1,.4,.9,.9,.4), gr =…
kbk78
  • 139
  • 4
2
votes
1 answer

How to omit to plot NA levels in geom_density_ridges2()

This question is related to this extend axis to 0 with geom_density_ridges2. Here the OP asks to extend the x axis to show 0, 1, 2 to the existing scale. While @stefan posted the correct answer using limits = c(-.5, 9.5), I tried an alternative way…
TarJae
  • 72,363
  • 6
  • 19
  • 66
2
votes
1 answer

How to replace quantile intervals in ridge plot with my own intervals?

With the R code below, library(ggplot2) library(ggridges) ggplot(iris, aes(x = Sepal.Length, y = Species)) + stat_density_ridges(quantile_lines = TRUE, quantiles = c(0.025, 0.975), alpha = 0.7) I get the following ridge plot I would like to…
bluepole
  • 323
  • 1
  • 12
2
votes
2 answers

Unable to colour jittered points in geom_density_ridges

I'm trying to colour specific points within a ridge plot, but the points I am trying to highlight aren't displayed nor are they in the legend. In this example I am trying to highlight the points with labels "X" and "Y" withing ridges based on groups…
Anton
  • 23
  • 3
2
votes
1 answer

Is there a way to fit this density plot into the frame better?

Dput Here is the dput for my data: work <- structure(list(Mins_Work = c(435L, 350L, 145L, 135L, 15L, 60L, 60L, 390L, 395L, 395L, 315L, 80L, 580L, 175L, 545L, 230L, 435L, …
Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30