简体   繁体   中英

ggplot2 avoid boxes around legend symbols

Consider the example plot below. I'd like to make the little boxes around each of the symbols in the legend go away. How an I do this?

 ggplot(mtcars, aes(wt, mpg, shape=factor(cyl))) + geom_point() + theme_bw()

You're looking for:

 + opts(legend.key = theme_blank())

You can see lots of examples of all sorts of this stuff in ?opts . I couldn't remember off the top of my head which one it was, so I just tried a few until I got it right.

Note : Since version 0.9.2 opts has been replaced by theme :

+ theme(legend.key = element_blank())

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