1

I want to specify the colour for each density in a ridgeline plot in R. I am using ggplot2 and ggridges.

I have tried the following here to produce a ridge plot, with no colours:

seq_plot_alt <- ggplot(seq_df, aes(x=x, y=as.factor(beta), fill = beta)) + 
  labs(title = 'Sequential', y = expression(beta), x = 'x', fill = expression(beta)) +
  geom_density_ridges(scale = 5) +
  theme_ridges(grid = FALSE, center_axis_labels = T) +
  scale_x_continuous(expand = c(0.01, 0)) +
  scale_y_discrete(expand = c(0.05, 0))

enter image description here

I have used the fill argument in the aes function to add some colour but I want to be able to specify the exact colours that each density plot is. So for each of these, I can specify say a vector of length 8 for each one.

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
user-2147482565
  • 453
  • 7
  • 16

0 Answers0