R语言 如何修改形状图例的大小?

xdnvmnnf  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(136)

对于使用ggplot2的简单绘图

library(ggplot2)
 ggplot(iris) +
geom_point(aes(Sepal.Length, Petal.Length, size = Sepal.Width, fill = Species), shape = 21)

字符串
我想减少图例大小的萼片宽度只(圆圈),我尝试

+
   guides(fill = guide_legend(override.aes = list(size=8)))


但这恰恰相反,并影响了传说spicies

ffscu2ro

ffscu2ro1#

上面写着Sepal.Width的图例是 size 指南,而不是 fill 指南。如果你只是想让点更小,你不需要触摸参考线。为此,您需要更改大小 * 比例 *
以下是原始情节:

library(ggplot2)

p <- ggplot(iris) +
  geom_point(aes(Sepal.Length, Petal.Length, size = Sepal.Width, fill = Species), 
             shape = 21)

p

字符串
x1c 0d1x的数据
如果要更改点的大小范围,请执行以下操作:

p + scale_size(range = c(0.2, 3))



创建于2023-07-20使用reprex v2.0.2

相关问题