带有四个变量的点图中的中心误差条(geom_errorbar)

时间:2016-05-30 14:45:53

标签: r ggplot2

我试图将错误栏与我的积分对齐。我使用的是ggplot2,这是我脚本的一部分:

pd <- position_dodge(0.9)

plot <- ggplot(sub.sum,aes(x=Type, y=Capture_Rate, colour=Gender))
plot <- plot + geom_point(aes(shape=Season),position=pd,size=5)
plot <- plot + geom_errorbar(aes(ymin=Capture_Rate-ci, ymax=Capture_Rate+ci),width=.2,position=pd)
plot <- plot + facet_wrap(~Species,scales="free_y",nrow=4,ncol=2)
plot <- plot + xlab("")+ ylab("Capture Rate (bats/mnh)")
plot <- plot + theme_bw() + scale_color_brewer(palette="Set1")
plot <- plot + expand_limits(y=0)
plot <- plot + theme(axis.title.x=element_text(size=20,vjust=-1))
plot <- plot + theme(axis.title.y=element_text(size=25,angle=90,vjust=2))
plot <- plot + theme(axis.text.x=element_text(size=16,face="bold",angle=20,vjust=0.5))
plot <- plot + theme(axis.text.y=element_text(size=18))
plot <- plot + theme(legend.text=element_text(size=20),
                     legend.title = element_blank(),legend.position="bottom", 
                     legend.key = element_blank()) 
plot <- plot + theme(plot.margin = unit(c(1.5,1.5,1.5,1.5),"cm"))
plot <- plot + theme(strip.text.x = element_text(face="italic",size=20))
plot <- plot + theme(strip.background = element_rect(fill = 'grey'))
plot <- plot + geom_vline(xintercept=c(1.5,2.5,3.5),color="red", linetype="dotted",size=1)
plot

当我没有季节时,我可以轻松地将错误中心与积分中心对齐。但是在添加了表示形状与Season相对应的代码之后,这是不可能的。以下是问题的一个示例:

Plot showing the problem

正如您在图像中看到的那样,错误条彼此重叠,它们不是以点为中心。它们只是图像的中心。我知道这是一个定位问题,但我不知道如何解决它。如果有人能帮助我,我将非常感激。

谢谢!

0 个答案:

没有答案
相关问题