【发布时间】:2020-03-19 02:17:37
【问题描述】:
我正在尝试将抖动图中点的颜色与框的颜色相匹配。我可以为它们着色一种或另一种颜色,但我似乎无法将它们设置为与框的颜色相匹配。
另外,我已经弄清楚如何使用 geom_jitter 更改抖动点的颜色,但似乎无法弄清楚如何将它们移动到箱线图的一侧,就像 geom_boxjitter 那样。我想也许我可以在我的 geom_jitter() 中添加“position = ...”,但这似乎不起作用...
带有黑点的抖动箱线图
具有正确色点但与框重叠的抖动箱线图
#hybrid jitter-box with jitter points all same colour
ggplot(all.bio2)+
geom_boxjitter(aes(x=season, y=S.chao1, fill=season),
jitter.colour = ,
outlier.colour = NULL, outlier.shape = 1,
errorbar.draw = T,
errorbar.length = 0.2)+
theme(panel.background = element_rect(fill = 'white', colour = 'black'))
#hybrid jitter-box with different coloured points but overlapping with boxes
ggplot(all.bio2)+
geom_boxjitter(aes(x=season, y=S.chao1, fill=season),
jitter.colour = NA,
outlier.colour = NA, outlier.shape = 1,
errorbar.draw = T,
errorbar.length = 0.2)+
geom_jitter(aes(x=season, y=S.chao1, colour=season), width = 0.15)+
theme(panel.background = element_rect(fill = 'white', colour = 'black'))
【问题讨论】:
-
对不起,我一开始没看懂你的问题,我编辑了我的代码,现在应该可以工作了
标签: r ggplot2 plot boxplot jitter