wilkelab / ggridges

Ridgeline plots in ggplot2
https://wilkelab.org/ggridges
GNU General Public License v2.0
411 stars 31 forks source link

Implement draw_quantiles like in geom_violin #9

Closed adrfantini closed 6 years ago

adrfantini commented 6 years ago

Title says it all, really. It'd be nice to be able to draw vertical quantiles, just like the quantiles that can be drawn by ggplot's geom_violin() using the option draw_quantiles

clauswilke commented 6 years ago

I'll probably have to add this feature at some point. It's frequently requested. In the meantime, note that you can color by quantiles. (Transparency is tricky in this case and needs to be specified in the hex codes for the colors).

ggplot(iris, aes(x=Sepal.Length, y=Species, fill=factor(..quantile..))) +
    geom_density_ridges_gradient(calc_ecdf = TRUE, quantiles = c(0.05, 0.95)) +
    scale_fill_manual(name = "Probability\nranges",
                      values = c("#FF0000A0", "#A0A0A0A0", "#0000FFA0")) +
    theme_ridges() + scale_y_discrete(expand = c(0.01, 0))
screen shot 2017-11-16 at 12 02 41 am
adrfantini commented 6 years ago

Oooh, this is nice. Could this be added to the examples vignette and/or to the manual? This can definitely be extremely useful.

clauswilke commented 6 years ago

It's in the documentation for stat_density_ridges() but probably needs to be featured more prominently or in a different location.

clauswilke commented 6 years ago

Drawing quantile lines is now possible.

ggplot(iris, aes(x=Sepal.Length, y=Species)) +
  geom_density_ridges(quantile_lines = TRUE, quantiles = c(0.25, 0.5, 0.75)) +
  scale_y_discrete(expand = c(0.01, 0)) +
  theme_ridges(grid = FALSE, center = TRUE)
screen shot 2017-11-18 at 3 35 35 pm
adrfantini commented 6 years ago

Thanks for the excellent work.

Adriano Fantini

2017-11-18 22:37 GMT+01:00 Claus Wilke notifications@github.com:

Closed #9 https://github.com/clauswilke/ggridges/issues/9.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/clauswilke/ggridges/issues/9#event-1348547030, or mute the thread https://github.com/notifications/unsubscribe-auth/AMO2HR5Of4DBNY5GkaB9p1nu4TRd9jkGks5s304HgaJpZM4QdEBq .