【问题标题】:Why does the shape of the legend's elements are not the same than the ones on the chart with `ggplot` in R?为什么图例元素的形状与 R 中带有 `ggplot` 的图表中的元素形状不同?
【发布时间】:2023-01-22 16:47:41
【问题描述】:
library(ggplot2)

ggplot(mtcars) + 
  aes(x = mpg, y = disp, size = cyl) + 
  geom_point() +
  geom_smooth(level = 0.99, method = "loess")  

如您所见,有在图表中,但有矩形传说中。

如何在图例中也有圆圈?

【问题讨论】:

    标签: r ggplot2 legend


    【解决方案1】:

    您不应该单独添加 ads,而是可以这样做:

    ggplot(mtcars, aes(x = mpg, y = disp)) + 
      geom_point(aes(size = cyl)) +
      geom_smooth(level = 0.99, method = "loess")  
    

    【讨论】:

      猜你喜欢
      • 2018-05-15
      • 2023-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-14
      • 2022-09-30
      • 2021-07-31
      • 2018-12-23
      相关资源
      最近更新 更多