![](/img/trans.png)
[英]How to remove the default grey fill for linetype legend in barplot with ggplot2?
[英]Remove grey from legend in ggplot2
我想从图例框中删除灰色(这是因为geom_smooth中的SE)。 我想将SE保留在实际情节中。 因此,在图例框中,我只想要线条的颜色,而不是阴影。 这是一个例子:
library(ggplot2)
x <- rnorm(100)
y <- rnorm(100)
g_ <- sample(c("group1", "group2"), 100, replace = TRUE)
ggplot(data.frame(x, y, g_), aes(x = x, y = y, color = g_)) + geom_smooth()
这是一种方法。 首先,以置信区间绘制线条,但没有图例。 然后,以无间隔和图例的方式绘制线条,最后,将图例键着色为白色。
ggplot(data.frame(x, y, g_), aes(x = x, y = y, color = g_)) +
geom_smooth(show_guide=FALSE) +
geom_smooth(fill=NA) +
theme(legend.key = element_rect(fill = "white"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.