Is there a way to colour the names or strip backgrounds (not the backgrounds of the actual grids, as has been answered in this post: Conditionally change panel background with facet_grid?) of the facets in ggplot2's facet_grid?
In the following example:
#create simple dataframe for plotting
xy <- data.frame(x = rep(1:10, times=3), y = rep(10:1, times=3), type = rep(LETTERS[1:2], each=5), type2 = rep(LETTERS[3:5], each=10), category = rep(c("control", "exp", "control"), each=10))
xy
#create base plot
plot <- ggplot(data = xy)+
geom_point(aes(x = x, y = y))+
facet_grid(type ~ type2)
#plot base plot
plot
Is there a way to colour the text or the background of theme(strip.text.x = element_text(size = 11, face="bold")) (?strip.background.x?) depending upon a categorical variable (for example, "category" in the data frame I have specified above, so all the controls have a red strip, all of the exp - a green one)?
Thanks in advance!
PS What I'm actually trying to do is present the results of a biological experiment:
two boxplots for every gene to show the variability; gene name is in the strip
the background of the grid is either white or grey, with grey showing genes which are controls
I'd like to use the colour of the text in the header to denote whether the gene is significant or not in my experiment (I need to show both the validated and non-validated genes in the same plot)