How to remove gray 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 

As a result:

ggplot2 gray border in legend

Each legend entry has a gray frame around it. How to remove it?

+5
source share
1 answer

Just add

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

enter image description here

+15
source

Source: https://habr.com/ru/post/1207025/


All Articles