[英]Subdividing jitter points in ggplot
我很难让geom_jitter
通过第三个变量(相位)分隔我的数据点。
我希望这个 2x2 图表中的每个条对于每个相位条件都有自己的一组抖动数据点。
现在,这些点被分组在两个阶段栏之间(抱歉无法上传图片——还没有我的 10 个帖子)。
我知道我在geom_jitter
aes 中遗漏了一些东西,但不确定它是什么——fill 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)
由代表 package (v0.3.0) 于 2020 年 7 月 9 日创建
使用以下方法找到了解决方案: geom_point(position=position_jitterdodge())
这似乎是在抖动和闪避以分离点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.