Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 控制绘图点的相对大小_R_Ggplot2 - Fatal编程技术网

R 控制绘图点的相对大小

R 控制绘图点的相对大小,r,ggplot2,R,Ggplot2,我试图控制以下ggplot中size=clarity参数的相对大小: library(ggplot2) diamonds %>% sample_n(100) %>% ggplot(aes(x = depth, y = price, color = cut, size = clarity)) + geom_point() 我试着玩shape=19,将size移动到geom_point()内部,但没有效果。我只想在情节中的形状更小(而不是图例)。有办法吗?您可以添加: + scal

我试图控制以下ggplot中
size=clarity
参数的相对大小:

library(ggplot2)
diamonds %>% 
sample_n(100) %>% 
ggplot(aes(x = depth, y = price, color = cut, size = clarity)) +
geom_point()
我试着玩
shape=19
,将
size
移动到
geom_point()
内部,但没有效果。我只想在情节中的形状更小(而不是图例)。有办法吗?

您可以添加:

+ scale_size_discrete(range = c(0.5, 4))
并使用范围值进行实验。默认值是c(1,6)


请注意有关尺寸和离散变量的警告信息。

我认为形状用于切割,颜色用于清晰可能是更好的可视化。此外,情节和图例中的大小将是相同的。太棒了!这是有效的,我不知道这个论点的存在。