Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

legend

ggplot2

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 grey border in legend

Each legend entry has a grey border around it. How to remove it?

like image 674
Gimelist Avatar asked Nov 17 '14 12:11

Gimelist


1 Answers

Just add

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

enter image description here

like image 62
tonytonov Avatar answered Sep 18 '22 12:09

tonytonov