小编lgb*_*gbi的帖子

在R中的ggplot2 geom_dotplot中使用填充美学时的重叠点

当我aes(fill=...)用来指示a中的因子水平时geom_dotplot,不同因子水平的点彼此重叠。尤其是对于大型数据集,这变得很麻烦。

下面,我提供了一个最小的示例和图形,其中我首先绘制了没有着色因子水平的数据集,然后添加fill以指示因子水平,这导致了点彼此重叠。如何避免这种情况?

我在这里知道类似的问题。但是,给出的答案不能解决此问题。

library("ggplot2")

n <- 200
x <- data.frame(x = sample(x = letters[1:3], size = n, replace = TRUE),
                y = rnorm(n = n, mean = 0, sd = 1),
                a = sample(x = letters[4:5], size = n, replace = TRUE))

p1 <- ggplot(x, aes(x = x, y = y))
p1 <- p1 + geom_dotplot(binaxis = "y", stackdir = "center")
p2 <- ggplot(x, aes(x = x, y = y, fill = …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

5
推荐指数
1
解决办法
882
查看次数

标签 统计

ggplot2 ×1

r ×1