在ggplot中细分抖动点

Subdividing jitter points in ggplot

我很难geom_jitter用第三个变量(相位)分隔我的数据点。

我希望此 2x2 图表中的每个条形图针对每个相位条件都有自己的一组抖动数据点。

现在这些点在两个相位条之间分组(抱歉无法上传图片——还没有我的 10 个帖子)。

我知道我在 geom_jitter aes 中遗漏了一些东西,但不确定是什么 -- fill=phase 没有成功。

ggplot(datalong, aes(grp, score)) +
  geom_bar(stat = "summary", fun.y = "mean", aes(fill=phase), position = "dodge", alpha = .5) +
  geom_jitter(inherit.aes = FALSE, aes(grp, score, fill=phase), position = position_jitter(0.2)) 

点的默认形状不采用填充美学

比较

library(ggplot2)
ggplot(mtcars, aes(mpg, disp, fill = gear)) +
  geom_jitter()

ggplot(mtcars, aes(mpg, disp, color = gear)) +
  geom_jitter()

ggplot(mtcars, aes(mpg, disp, fill = gear)) +
  geom_jitter(shape = 21)

reprex package (v0.3.0)

于 2020-07-09 创建

使用以下方法找到解决方案: geom_point(位置=position_jitterdodge())

这个好像抖动和闪避要分开点