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
1
vote
0 answers

Move line segments to front with stat_density_ridges

I have a dataframe with different groups ('label' column). For each label, I want to plot a null distribution obtained from bootstrapping (values are in the 'null' column) and the true statistic on top as a line (value in the 'sc' column). Ideally,…
TanZor
  • 227
  • 1
  • 6
1
vote
1 answer

Can I use different cutoff points for different groups with stat_density_ridges?

I have a dataframe with different groups ('label' column). For each label, I want to plot a null distribution obtained from bootstrapping (values are in the 'null' column) and the true statistic on top (value in the 'sc' column). Ideally, I would…
TanZor
  • 227
  • 1
  • 6
1
vote
1 answer

Additional color layer for geom_density_ridges()

I found below example: library(ggplot2) library(ggridges) ggplot(iris, aes(x = Sepal.Length, y = Species)) + geom_density_ridges( jittered_points = TRUE, position = position_points_jitter(width = 0.05, height = 0), point_shape = '|',…
yuw444
  • 380
  • 2
  • 10
1
vote
3 answers

R: How to set full transparency in a quantile line in geom_density_ridges

First of all, some data similar to what I am working with. rawdata <- data.frame(Score = rnorm(1000, seq(1, 0, length.out = 10), sd = 1), Group = rep(LETTERS[1:3], 10000)) rawdata$Score <- ifelse(rawdata$Group == "A",…
Unai Vicente
  • 367
  • 3
  • 10
1
vote
0 answers

Display mean and median avoiding overlaping ggridges

I'm working on a temperature data set over time and I used a density ridges plot to visualize my data by month. On each plot I included the median and the mean by using 2 geom_density_ridges_gradient function. The reason why I used two…
HMK
  • 47
  • 4
1
vote
1 answer

How to change items in a ggplot2 legend?

I am trying to change the legend items of this plot. My code is: library(ggplot2) library(HDInterval) library(ggridges) df <- data.frame( density = c(rgamma(400, 2, 10), rgamma(400, 2.25, 9), rgamma(400, 5, 7)), source = rep(c("source_1",…
Kirds
  • 131
  • 7
1
vote
1 answer

ridgeline plot with frequencies (count) instead of density, on second y-axis and rectangle background

I would like to add frequencies on a second y-axis to a ridgeline plot using ggplot2 and ggridges I found a tutorial adding the frequencies as numbers with geom_text (https://rdrr.io/cran/ggridges/man/stat_binline.html), however, I would prefer to…
ava
  • 840
  • 5
  • 19
1
vote
1 answer

stack bars with stat_binline()

I have data similar to the example below. I am wanting to visualise the spread of the outcome variable (value) for each group (name). The fill aesthetic is the desired interval - the example below uses the interquartile range. I would expect the…
Rex Parsons
  • 199
  • 10
1
vote
1 answer

ggplot/ggridges order of is mixed up when adding layers

I am in need of some assistance. I am using ggridges but I end up with the problem exemplified below: I get a bad order i.e. (1, 10, 11, 2) of the y axis. I would like the y-axis order of the last figure to be (1, 2, 3, 10, 20) Code…
jack kelly
  • 320
  • 1
  • 8
1
vote
1 answer

how to increase white space at top of panel when using geom_density_ridges()

When I make a plot using geom_density_ridges() the top most plot touches the top of the panel. How do I create a little white space there for aesthetic purposes? library(ggplot2) library(ggridges) ggplot(iris, aes(x = Sepal.Length, y = Species)) +…
Joe
  • 3,217
  • 3
  • 21
  • 37
1
vote
1 answer

How to fill color in ggridges based on height aesthetics?

I am trying to create ggridges plot with Covid19 Cases counts for various States. I would like to fill the color based on Cases counts & Not based on States but unable to do so. I have attempted below code so…
ViSa
  • 1,563
  • 8
  • 30
1
vote
1 answer

R ggplot2 Prevent vline from appearing in empty ggridge facet

I'm trying to produce a faceted ridgeplot, where some ridges are empty. The code below produces an example. library(ggridges) library(tidyverse) df <- tibble(x = rnorm(1000, 1, 1), id = c(rep(1, 600), rep(2, 400)), year =…
ADF
  • 522
  • 6
  • 14
1
vote
2 answers

Stacked histograms with ggridges package in R

The following code produces histograms that overlap. How can I modify this code to make the histograms stack on top of each other? library(tidyverse) library(ggridges) iris %>% pivot_longer(cols = -Species, names_to =…
Sasha
  • 5,783
  • 8
  • 33
  • 37
1
vote
1 answer

How can I make this ggplot render more quickly?

Below is a reprex of the data I'm working with. The geom_segment calls make the rendering very sluggish. Is there an alternate way to achieve the same result more quickly? library(ggplot2) library(ggridges) n <- 5000; l <- c(2, 5, 7, 9); sd_27 <-…
saheed
  • 340
  • 2
  • 12
1
vote
0 answers

How to use varying quantiles to highlight the tails of the corresponding distributions in R with ggridges?

Take the data "diamond" for example, library(ggplot2) library(ggridges) ggplot(diamonds, aes(x = price, y = cut,fill = factor(stat(quantile)))) + stat_density_ridges( geom = "density_ridges_gradient", calc_ecdf = TRUE, …
Zzx Zhang
  • 11
  • 1