oob = scales :: squish无法在ggplot2中与scale_size_continuous一起使用

问题描述

这与这里的问题有关:Adjust geom_point size so large values are plotted,but do not appear larger in ggplot2?

具体参考@Axeman的回复

我无法对此问题发表评论,因此不得不提出一个新问题。

我希望对az acr repository show-manifests -n myRegistryName --repository myRepositoryName --query '[].tags[0]' -o yaml | grep '[0-7]2020-' | sed 's/- /az acr repository delete --name myRegistryName --yes --image myRepositoryName:/g' 的磅值实现“压缩”,但是选项geom_pointoob=scales::squish不兼容。我不确定我还想念什么。

非常感谢您的帮助。这是我尝试的代码

scale_size_continuous

此外,我想补充一点,因为我不希望将0值映射到大小为0的点,所以不能使用@Axeman回答的xx = ggplot(pcm,aes(x = variable,y = TF)) + geom_point(aes(size = value,fill=value),shape = 21) + scale_size_continuous(range=c(1,12),limits = c(-2,2),oob = scales::squish) 。从-1.7到+3。我想要为最小的负值分配最小的大小。谢谢。

解决方法

如果在value上进行转换会不会有问题?

在这里,我只是想像您的数据如何:

pcm <- data.frame(variable = runif(100),TF       = runif(100),value    = runif(100,-1.7,3))

这是情节

library(ggplot2)

ggplot(pcm,aes(x = variable,y = TF)) + 
    geom_point(aes(size = pmax(pmin(value,2),-2),fill = value),shape = 21) +
    labs(size = "value")

enter image description here

让我知道,我也许可以改善答案。

我也建议您进行一些更新以提高图表的可读性,但这取决于您。

ggplot(pcm,colour = value),alpha = 0.6) +
    labs(title = "Dots and colours",size = "value") +
    theme_minimal()

enter image description here