简体   繁体   中英

ggplot2 - R - How to fix size of bubble in legend

I would like to make the shape that shows the bubble color larger in the legend only. I have tried several suggestions from this site, but I have been unlucky so far. A basic example is below.

In this example, I would like for the "gear" size to be 10. This is probably too large, but I wanted to verify it was working first.

library(ggplot2)
ggplot(mtcars
       ,aes(x=hp, y=disp, size=mpg, fill=factor(gear)))+
geom_point(shape=21)+
theme_bw()+
scale_size_continuous(range=c(2,15))+
guides(shape = guide_legend(override.aes = list(size = 10)))

MT汽车图图输出

更改shapefill guides将重新缩放图例元素的大小:

 guides(fill = guide_legend(override.aes = list(size = 10)))

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