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 replace the two quantile lines (2.5% and 97.5%) under each density plot with two different lines based on the following code:
require(coda)
aggregate(Sepal.Length ~ Species, iris, function(x) HPDinterval(as.mcmc(x), 0.975))
In other words, I wish to put those vertical lines at the following locations:
Species Sepal.Length.1 Sepal.Length.2
1 setosa 4.3 5.8
2 versicolor 4.9 7.0
3 virginica 4.9 7.9
How to achieve this?