iilla
iilla

Reputation: 105

Lines overlapping in R with ggridges

I use ggridges in R to visualize my data. But a lot of the lines are overlapping and are hard to read.

enter image description here

My code is:

ggplot(task1, aes(x = ibu, y = style, fill = style)) +
  geom_density_ridges(alpha=1) +
  theme_ridges() + 
  theme(legend.position = "none")

What should I change to make this visualization more readable?

Upvotes: 2

Views: 1494

Answers (1)

Claus Wilke
Claus Wilke

Reputation: 17790

You can use the scale parameter to adjust the overall height scaling. Just set it to a number that produces results you like.

library(ggplot2)
library(ggridges)
#> 
#> Attaching package: 'ggridges'
#> The following object is masked from 'package:ggplot2':
#> 
#>     scale_discrete_manual

ggplot(iris, aes(x = Sepal.Length, y = Species, fill = Species)) +
  geom_density_ridges()
#> Picking joint bandwidth of 0.181

ggplot(iris, aes(x = Sepal.Length, y = Species, fill = Species)) +
  geom_density_ridges(scale = 0.5)
#> Picking joint bandwidth of 0.181

Created on 2019-11-03 by the reprex package (v0.3.0)

Upvotes: 2

Related Questions