去除带背景保持面板边框 [英] Remove strip background keep panel border

查看:169
本文介绍了去除带背景保持面板边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类型的情节,并希望将每个条状文本保留在各个方面框上作为各种标题,但在 strip.background周围没有默认的灰色背景和黑色边框。我把它变成白色,它接近我想要的,但是会想要 strip.background 的下边缘或 panel.border 变黑。



  library(ggplot2)

ggplot(mtcars,aes(mpg,hp) )+
theme(panel.grid.major = element_blank(),
panel.grid.minor =
strip.background = element_rect(color =white,fill =white),
panel.border = element_rect(color =black))
<如果你设置元素_bnk()


解决方案 c>为 strip.background 并保留 element_rect(color =black)用于面板.border ,那么 panel.border 的上边缘会变黑。

  ggplot(mtcars,aes(mpg,hp))+ ge om_point()+ 
facet_wrap(〜carb,ncol = 3)+ theme_bw()+
主题(panel.grid.major = element_blank(),
panel.grid.minor = element_blank ),
strip.background = element_blank(),
panel.border = element_rect(color =black))


I have the following type of plot and want to keep each strip text above the individual facet box as a "title" of sorts yet not have the default grey background and black border around the strip.background. I color it white which is close to what I want but would like the bottom edge of the strip.background or top edge of panel.border to be black.

library(ggplot2)

ggplot(mtcars, aes(mpg, hp)) + geom_point() +
    facet_wrap(~carb, ncol = 3) + theme_bw() +
    theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        strip.background = element_rect(colour="white", fill="white"),
        panel.border = element_rect(colour = "black"))

解决方案

If you set element_blank() for strip.background and keep element_rect(colour="black") for panel.border then top edge of panel.border will be black.

ggplot(mtcars, aes(mpg, hp)) + geom_point() +
  facet_wrap(~carb, ncol = 3) + theme_bw() +
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        strip.background = element_blank(),
        panel.border = element_rect(colour = "black"))

这篇关于去除带背景保持面板边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆