使用ggplot绘制堆积点

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

我有一个数据框,我想将完全重叠的点堆叠在一起。

这是我的示例数据:

value <- c(1.080251e-04, 1.708859e-01, 1.232473e-05, 4.519876e-03,2.914256e-01, 5.869711e-03, 2.196347e-01,4.124873e-01, 5.914052e-03, 2.305623e-03, 1.439013e-01, 5.407597e-03, 7.530298e-02, 7.746897e-03)
names = letters[1:7]
data <- data.frame(names = rep(names,), group = group, value = value, stringsAsFactors = T)
group <- c(rep("AA", 7) , rep("BB", 7))

我正在使用以下命令:

p <- ggplot(data, aes(x = names, y = "", color = group)) + 
geom_point(aes(size = -log(value)), position = "stack") 
plot(p)

但是堆叠的圆圈在网格外。我希望它靠近或正好靠近底部圆。您知道如何解决该问题吗?

谢谢,enter image description here

r ggplot2 plot grid
1个回答
1
投票

y轴没有数值,因此请使用group。由于组标签显示在y轴上,因此我们现在不需要颜色图例。

ggplot(data, aes(x = names, y = group, color = group)) + 
  geom_point(aes(size = -log(value))) +
  guides(color=FALSE)

enter image description here

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