Position dodge with error bars in ggplot2

2019-08-02 16:55发布

问题:

I am trying to use ggplot to show a series of confidence intervals across different time points. I have two sets of confidence intervals, one parametric and one bootstrap, and I would like to display them using geom_errorbar(). I tried using position_dodge() so the two CI won't directly overlay one another, but it is not working. How do I jitter the CI at the same time point?

pd <- position_dodge(.6)
ggplot(results, aes(x=intervals, y = change)) +
geom_errorbar(aes(ymin=ci.par.low, ymax=ci.par.hi), position = pd, width=.1, colour =
"green") + 
geom_errorbar(aes(ymin=ci.boot.low, ymax=ci.boot.hi),  width=.1, colour = "blue") +
geom_abline(intercept = slope.est, slope = 0, colour = "red") +
labs(title = paste("Protein ID:", prot.name))

回答1:

I accomplished my goal with position_jitter(), though it's clunky.



标签: r ggplot2