我喜欢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
主题而无需手动重新定义整个事物?
答案 0 :(得分:1)
cowplot
主题将rects的默认线型设置为0,这意味着'透明':
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))