【问题标题】:How to remove the grey background from a facet_grid() (ggplot2) [duplicate]如何从 facet_grid() (ggplot2) 中删除灰色背景 [重复]
【发布时间】:2015-07-13 17:22:28
【问题描述】:

我有以下情节:

通过执行获得:

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 后面的灰色背景。

我希望它是白色的,而不改变我目前使用的其余主题。

【问题讨论】:

  • 谢谢!我应该怎么处理这个帖子?删除它?

标签: r ggplot2 facet


【解决方案1】:

在谷歌上搜索了一下之后,我找到了this post,它解释了可以应用于facet 的不同操作。

原来我的问题可以通过以下方式解决:

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

theme() 中使用strip.background = element_rect(colour="red", fill="#CCCCFF") 就可以了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    相关资源
    最近更新 更多