I'm using facet_wrap
to look at data from individual replicates at "low power." I want to highlight facet titles by coloring the text of specific values a distinct color. In my actual data, I am using the color element to graph a different variable, so it's unavailable.
A similar thread is here, but the solution is rather clunky.
As an example, I'll demonstrate with the diamonds dataset:
library(tidyverse)
diamonds %>%
ggplot(aes(x = carat, y = price))+
geom_point()+
facet_wrap (cut ~ clarity)
I'm most interested in diamonds with "Premium" cut, so I want the facet text that says "Premium" to be red, while everything else stays the same.
I tried defining my color and then adding it through the theme element:
mycolor <- c("Premium" = "red")
diamonds %>%
ggplot(aes(x = carat, y = price))+
geom_point()+
facet_wrap (cut ~ clarity)+
theme(strip.text = element_text(mycolor))
this produces a warning:
Warning: no font could be found for family "red"
Warning: no font could be found for family "red"
Warning: Unable to calculate text width/height (using zero)
but still generates a graph: