ggplot geom_point 使用 aes 时使点变大

问题描述 投票:0回答:2

在 ggplot 中,我想让

geom_point
在 aes 中时整体更大。例如:

ggplot(diamonds %>% head(30)) +
  geom_point(aes(x = cut, y=color, size=carat))

提供与

完全相同的情节
ggplot(diamonds %>% head(30)) +
  geom_point(aes(x = cut, y=color, size=10*carat))

你可以在 aes 之外执行此操作,但在 aes 内不起作用

ggplot(diamonds %>% head(30)) +
  geom_point(aes(x = cut, y=color), size=10))
ggplot2 geom-point
2个回答
0
投票

来自@teunbrand 评论:

ggplot(diamonds %>% head(30)) +
  geom_point(aes(x = cut, y=color, size=carat)) +
  scale_size(range = c(0, 40))


0
投票

如果您使用面积修改器修改 aes 的大小,则可以使用

max_size
参数来控制点可以获得的大小,从而有效地缩放点。

ggplot(diamonds %>% head(30)) +
  geom_point(aes(x=cut, y=color, size=carat)) +
  scale_size_area(max_size = 9)

此示例的效果非常小,因为克拉值在一个狭窄的范围内。

(面积修改器与

size
aes 一起使用来缩放点的 area 而不是半径)

© www.soinside.com 2019 - 2024. All rights reserved.