【问题标题】:ggplot2 - R - How to fix size of bubble in legendggplot2 - R - 如何修复图例中气泡的大小
【发布时间】:2018-03-30 14:35:36
【问题描述】:

我想仅在图例中使显示气泡颜色的形状更大。我已经尝试了这个网站的几个建议,但到目前为止我一直很不走运。下面是一个基本示例。

在此示例中,我希望“齿轮”的大小为 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)))

【问题讨论】:

    标签: r ggplot2 bubble-chart legend-properties


    【解决方案1】:

    guides 中的shape 更改为fill 将重新调整图例元素的大小:

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

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 2022-01-13
      • 2011-12-23
      • 2023-01-24
      • 2018-06-10
      • 1970-01-01
      • 2018-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多