如何在使用facet_grid时更改构面边框的颜色 [英] How to change color of facet borders when using facet_grid
本文介绍了如何在使用facet_grid时更改构面边框的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用 facet_grid
时, ggplot2
会将构成方面变量的主要类别用大于 - 通常的白线。这非常适合大多数目的。有时我想更清楚地显示这些主要分类之间的分歧,并希望以另一种颜色遮蔽分面。有没有办法做到这一点?感谢。
When using facet_grid
, ggplot2
divides the major categories that make up the facet variables with a broader-than-usual white line. This serves most purposes well. Sometimes I want to more clearly show the divisions between these major categorizations and would like to shade the facet division with another color. Is there a way to do that? Thanks.
推荐答案
尽管一年后,我发现这是一个简单的解决方案:
Although a year late, I found this to be an easy fix:
ggplot(mpg, aes(cty, hwy, color = factor(year)))+
geom_point()+
facet_grid(cyl ~ drv) +
theme(panel.margin=unit(.05, "lines"),
panel.border = element_rect(color = "black", fill = NA, size = 1),
strip.background = element_rect(color = "black", size = 1))
这篇关于如何在使用facet_grid时更改构面边框的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文