【发布时间】:2017-01-03 08:11:42
【问题描述】:
是否可以为 ggplot2 facet_wrap 中使用的每个变量设置独立的条形主题?
以这段代码为例:
p1 <- ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(c("cyl", "drv"), labeller = "label_both")
plot(p1)
我希望上条('cyl')具有不同的主题 - 比如说,粗体。此外,我可能想让“drv”斜体并使用不同的字体类型和大小。我怎么能这样做?
我在想一些事情:
p1 <- p1 + theme(strip.text.variable1 = element_text(face = 'bold'),
strip.text.variable2 = element_text(face = 'italic', size = 8)
)
很遗憾,我在文档或以前的问题中找不到类似的内容。
干杯
编辑:我把这个问题写得更笼统一些,以便对社区有进一步的帮助。
【问题讨论】:
标签: r ggplot2 facet-wrap