Missing horizontal line on error bar

1,937 views
Skip to first unread message

Sarah

unread,
Oct 7, 2010, 7:29:20 PM10/7/10
to ggplot2
Using this script, my plot has missing horizontal bars on the error
bars. If I swap the x variable to 'Group' and shape to 'Gap', then
the error bars are complete. This is however not the plot I want!

qplot(x = Gap, y= MeanLatency, ylab = "Latency (ms)", ylim = c(0,
300),data = group.means.lat.gap, shape=Group) + geom_point(size=3)
+geom_line(size=1)+ geom_errorbar(limits, width=0.06)
+scale_x_continuous(breaks=c(-200,0))

Also how does one offset slightly two objects on the same x-axis
point?

Any suggestions?

Brandon Hurr

unread,
Oct 8, 2010, 2:55:19 AM10/8/10
to Sarah, ggplot2
Sarah, 

It's pretty hard to say without your data what is going on. Generally, shape should be a factor of some sort, which would indicate to me that you shouldn't easily be able to simply switch Group and Gap with scale_x_continuous() since they are likely to be discrete. Have you tried increasing the width of the bar? 0.06 is kind of small and if your scale differs between the two then maybe 0.06 is so small that you can't see it. Set it to 1 or 10 and just see what happens. 

As far as putting points next to each other you could try setting position="jitter" in geom_point() or or use geom_jitter(). I'm not sure if you can connect points with a line if you use jitter though.


I assume that limits is something like this:
limits<- aes(ymax=mean+se, ymin=mean-se)

ggplot(data = group.means.lat.gap, aes(x = Gap, y = MeanLatency))+
geom_point(aes(shape=Group), size=3)+
geom_errorbar(limits, width=0.06)+
geom_line(size=1)+
scale_x_continuous(breaks=c(-200,0))+
scale_y_continuous("Latency (ms)", limits = c(0,300))
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Reply all
Reply to author
Forward
0 new messages