2017-10-18 241 views
1

我想使图形中只显示气泡颜色较大的图形。我已经尝试了几个来自这个网站的建议,但到目前为止我一直不走运。一个基本的例子如下。ggplot2 - R - 如何修复图例中气泡的大小

在这个例子中,我想“齿轮”的大小为10.这可能太大,但我想验证它是第一次工作。

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 Cars Plot Plot Output

回答

1

guides更改shapefill将重新分的图例的该元素的尺寸:

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