I would like to color a specific area, where col_bol = 1
in a ggridges
density curve plot. I know its possible to do this using stat_density_ridges()
providing quantiles. If I dont have the quantiles I calculate the percent. This works if it's only one plot without facets.
How could I achieve it using the data below?
library(tidyverse)
library(ggridges)
plot_data <- iris %>% gather(key = 'key', value = 'value', -Species) %>% mutate(col_bol = case_when(
Species == 'setosa' & (value < 1.5 | value > 6) ~ 1,
Species != 'setosa' & (value < 1.3 | value > 6.2) ~ 1,
TRUE ~ 0))
ggplot(data = plot_data, mapping = aes(y = key, x = value)) +
geom_density_ridges() +
facet_wrap(~Species, scales = 'free_x') +
theme_ridges()