【发布时间】:2014-03-17 15:10:14
【问题描述】:
有没有办法为 ggplot2 的 facet_grid 中的 facet 的名称或去除背景(不是实际网格的背景,如本文中已回答:Conditionally change panel background with facet_grid?)着色?
在以下示例中:
#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
有没有办法根据分类变量为主题的文本或背景着色(strip.text.x = element_text(size = 11, face="bold")) (?strip.background.x?) (例如,我上面指定的数据框中的“类别”,所以所有控件都有一个红色条,所有的 exp - 一个绿色)?
提前致谢!
PS 我真正想做的是展示一个生物实验的结果:
每个基因的两个箱线图显示变异性;基因名称在条带中
网格的背景是白色或灰色,灰色表示控制基因
我想使用标题中文本的颜色来表示该基因在我的实验中是否重要(我需要在同一个图中显示已验证和未验证的基因)
【问题讨论】:
-
我很好奇this 是否仍然有效。