简体   繁体   English

如何在使用theme_bw时删除ggplot2图例中各个条目周围的灰色边框?

[英]How to remove grey borders around individual entries in ggplot2 legend when using theme_bw?

I have the following code in R: 我在R中有以下代码:

library(ggplot2)
theme_set(theme_bw())
p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point(aes(colour = factor(cyl)))
p

Resulting in this: 结果如下:

传奇中的ggplot2灰色边框

Each legend entry has a grey border around it. 每个图例条目都有一个灰色边框。 How to remove it? 如何删除它?

Just add 只需添加

+ theme(legend.key = element_rect(colour = NA))

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM