简体   繁体   中英

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

I have the following code in 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))

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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