-----Original Message-----
From: adamjgabbert at gmail.com
Sent: Thu, 26 Jul 2012 09:03:44 -0400
To: r-help at r-project.org
Subject: [R] Error Bars ggplot2
Hello,
I'm attempting to plot error bars side by side rather than stacked on top
of each other with ggplot2. Here is the sample code I am using:
#Code
#Data
spd<-c("s","f","f","s","f","s","s","s","f","f","s","f")
r<-c(4.9,3.2,2.1,.2,3.8,6.4,7.5,1.7,3.4,4.1,2.2,5)
#Turn spd into a factor
spd.f<-factor(spd)
#Place data into a data frame
data<-data.frame(cbind(spd.f,r))
#Load ggplot2
library(ggplot2)
#Create plot
pd<-position_dodge(.2)
myplot<-ggplot(data,aes(x=spd,y=r,colour=spd))+
geom_errorbar(aes(ymin=3,ymax=5),width=.1)+
geom_point()+
geom_errorbar(aes(ymin=1,ymax=6),width=.1,colour="black",position=pd)
#Display plot
myplot
I have attached a plot that my sample code produces. As you can see the
error bars are stacked. How can I get them to plot side by side?
Thanks
AG