更改 cowplot 主题的默认设置
Alter default settings for cowplot theme
我喜欢 cowplot
的默认主题,但我想做一些改动。例如,我希望能够调整 legend.key
的默认值。 MWE,
library(ggplot2); library(cowplot)
plt = ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) + geom_point() + theme(legend.key = element_rect(color = 'black'))
plt
然而,这不起作用。
有什么方法可以调整 cowplot
主题而不必手动重新定义整个该死的东西吗?
cowplot
主题将rects的默认线型设置为0,即'transparent':
rect = element_rect(fill = "transparent", colour = NA, color = NA, size = 0, linetype = 0)
覆盖该默认值可为您提供所需的内容:
library(ggplot2)
library(cowplot)
ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) +
geom_point() +
theme(legend.key = element_rect(color = 'black', linetype = 1))
我喜欢 cowplot
的默认主题,但我想做一些改动。例如,我希望能够调整 legend.key
的默认值。 MWE,
library(ggplot2); library(cowplot)
plt = ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) + geom_point() + theme(legend.key = element_rect(color = 'black'))
plt
然而,这不起作用。
有什么方法可以调整 cowplot
主题而不必手动重新定义整个该死的东西吗?
cowplot
主题将rects的默认线型设置为0,即'transparent':
rect = element_rect(fill = "transparent", colour = NA, color = NA, size = 0, linetype = 0)
覆盖该默认值可为您提供所需的内容:
library(ggplot2)
library(cowplot)
ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) +
geom_point() +
theme(legend.key = element_rect(color = 'black', linetype = 1))