【发布时间】:2017-03-02 08:09:54
【问题描述】:
我正在尝试为我制作的常见情节创建一个自定义的首选主题。在这些图中,我希望仅在图分面时才包含网格线。
例如,我在写了一些主题函数theme_my() 这样如果我写:
library(ggplot2)
theme_set(theme_my())
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(~class)
ggplot(mpg, aes(displ, hwy)) +
geom_point()
结果是一样的
library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(~class)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
基本上,我想知道是否可以在我的主题函数中包含一些内容,以便在情节分面时模板使用最终的+theme(panel.grid.major ...) 调用。这可能吗?或者还有其他更好的方法吗?
【问题讨论】: