如何从facet_grid()(ggplot2)中移除灰色背景

3

我有以下的图表:

在此输入图片描述

通过执行以下命令得到:

ggplot() + 
  stat_summary( data = test_data1, aes(x=x, y=(1-value) , colour = as.factor(1) , lty = as.factor(1) ) , fun.y=mean, geom="line" ,  size=1 ) +
  stat_summary( data = test_data1, aes(x=x, y=(1-value) , colour = as.factor(1), shape=as.factor(1) ) , fun.y=mean, geom="point" ,  size=3, pch=21, fill="white" ) +
  stat_summary( data = test_data2, aes(x=x, y=(1-value) , colour = as.factor(2), lty = as.factor(2) ) , fun.y=mean, geom="line", size=1 ) +
  stat_summary( data = test_data2, aes(x=x, y=(1-value) , colour = as.factor(2), shape=as.factor(2)) , fun.y=mean, geom="point", size=3, pch=21, fill="white" ) +
  theme_bw(base_size = 14, base_family = "Palatino") + 
  theme(legend.key = element_blank() ) +
  expand_limits(x=c(0), y=c(0)) +
  facet_grid(distance ~ . ) 

我该如何消除出现在100200后面的灰色背景?

我希望这个背景变为白色,但不想改变我当前使用的主题中的其他部分。


谢谢!我应该对这个帖子做什么?删除它吗? - undefined
1个回答

7

在谷歌上搜索了一些后,我发现这篇文章介绍了可以应用于facet的不同操作。

结果我的问题可以通过以下方式解决:

theme(legend.key = element_blank(), strip.background = element_rect(colour="red", fill="#CCCCFF") ) 

theme()内使用strip.background = element_rect(colour="red", fill="#CCCCFF")可以完成此操作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接