I am trying to color a portion of the y-axis tick labels in a ridges plot. My data are similar to the following:
library(tidyverse)
set.seed(10)
dt <- data.frame("T1.C1" = rnorm(10, mean = -10),
"T2.C2" = rnorm(10, mean = -5),
"T3.C3" = rnorm(10, mean = 5),
"T4.C4" = rnorm(10, mean = 10))
data <- dt %>%
gather(.) %>%
mutate(., hl = case_when(key == "T1.C1" ~ "T1",
key == "T3.C3" ~ "C3"))
In this case, the ridges plot looks like the following:
ggplot(data, aes(x = value, y = key)) +
geom_density_ridges() +
theme_ridges() +
theme(axis.title.y = element_blank())
I would like to color the portion of the y-axis tick labels based on the hl
column of the data set entitled data
. So, for the density plot associated with the data for the T1.C1
and T3.C3
experiments, I would like the T1
and C3
to be colored red where there is no special coloring for the other experiments given that hl
is NA
.
I assume there is some parsing argument that I can take advantage of, but I am not sure where to start. Any suggestions would be greatly appreciated. :)