开发者

dodged geom_point in ggplots for presenting estimate of an errorbar

I am using the following code for presenting some measurements, their estimates and their CI:

ssi.oe.cutoffs.chart <- ggplot(data=oe.chart.data, aes(x=core_ot_code_mod, colour=cutoff))
ssi.oe.cutoffs.chart <- ssi.oe.cutoffs.chart + geom_hline(yintercept=1)
ssi.oe.cutoffs.chart <- ssi.oe.cutoffs.chart + geom_errorbar(aes(ymin=lcl95, ymax=ucl95, width=0.5),position="dodge")
ssi.oe.c开发者_运维问答utoffs.chart <- ssi.oe.cutoffs.chart + geom_errorbar(aes(ymin=SIR, ymax=SIR, width=0.5),position="dodge")

core_ot_code_mod is a discrete variable, and the geom_errorbar works perfectly for me, showing 2 dodged errorbar with different colour, but I can't use the similar code to let the geom_point present the same way. And I am using another geom_errorbar as replacement, which is not very nice.

Can anyone here enlighten me? Thanks!


geom_point requires explicit specification of width of the dodge.
here is a minimal example:

d <- data.frame(expand.grid(x=letters[1:2], co=letters[3:4]), y=runif(4))
d <- transform(d, Lo=y-1, Hi=y+1)

ggplot(d, aes(x, y, colour=co)) + 
  geom_point(position=position_dodge(width=0.3)) +
  geom_errorbar(aes(ymin=Lo, ymax=Hi), width=0.15, 
    position=position_dodge(width=0.3))

the width=0.15 specifies the width of the errorbar.
the width=0.3 inside position_dodge specifies the width of dodgin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜