我在 ggplot 中使用 facet wrap 来创建箱线图。我正在使用填充命令按颜色进一步分解数据。使用其他 stackoverflow 帮助,我已经能够在这些箱线图上添加点。我现在试图将这些点集中在每个箱线图上。正如您在屏幕截图中看到的,这些点实际上以 x 轴上的变量“盐”为中心,而不是以它们各自的箱线图为中心。您对如何处理这个问题有什么建议吗?
非常感谢您的帮助!
我的代码:
I<-ggplot(IntTrt72, aes(x=salt, y=rel_diff, fill = stage))+
geom_boxplot(outlier.size = 0.1) + theme_classic() +
theme(strip.background = element_blank(), strip.text.x = element_blank(), legend.position = "none")+
geom_dotplot(binaxis = 'y', stackdir = 'center', binwidth = .05,
color = NA,position = position_dodge())
I<-I+scale_fill_manual(values=c("#5445b1", "#749dae", "#f3c483"))+ theme_classic()+
theme(strip.background = element_blank(), strip.text.x = element_blank(), legend.position = "none")
I<- I+facet_wrap(treatmenthours~temp)
I<- I + geom_hline(yintercept=0, linetype="dashed", color = "grey60")
I<- I + scale_y_continuous( breaks=c(-1.0, -0.75, -0.5, -0.25, 0, 0.25), limits=c(-1.0, 0.3))
I
仅供参考,我是 R 初学者。