我想在箱线图中显示点,但是我只有阶段4的一些数据,这意味着我缺少阶段4的一个框。因此,我不能将点保持在框的中心线上。以下是我的R代码和图形:
p = ggplot(vaginal_data,aes(x=as.factor(Stage),y=shannon))+ggtitle("shannon")+xlab("Stage")+ylab("Shannon Index")+scale_x_discrete(limits=c("1","2","3","4"))+scale_fill_brewer(palette="Set1")
p = p+theme_set(theme_bw())+theme(plot.title = element_text(hjust = 0.5),axis.text.x = element_text(angle = 90, hjust = 1))
p = p+geom_boxplot(aes(fill=Bred_Open),position = position_dodge2(preserve = "single"))
p = p + geom_point(position=position_dodge(width=0.75),aes(group=Bred_Open))