Nikky,

It is helpful if you provide a simplified version of your question with
data.  For example:

# simplified example
y <- c(2.2, 2.4, 2.35, 2.45)
upper <- 0.17
lower <- upper

# current plot, with default base of 0
b <- barplot(y, ylim=c(2, 3))
arrows(b, y+upper, b, y-lower, angle=90, code=3)


It is also helpful if you say exactly what it is that you want.  My guess
is that you don't want to use the standard of y=0 as the base for your bar
heights.  To change this use the offset argument of the barplot() function,
and be sure to subtract this base from the heights if you want the values
on the y-axis to remain the same.  For example:

# new plot, with specified base for bar heights
base <- 2
b <- barplot(y-base, ylim=c(2, 3), offset=base)
arrows(b, y+upper, b, y-lower, angle=90, code=3)

Jean



On Fri, May 31, 2013 at 11:31 AM, Nicole Prause <nprause@mednet.ucla.edu>wrote:

> The code below produces the plot hosted here:
> http://www.span-lab.com/ChartStop.jpeg
>
>     error.bar <- function(x, y, upper, lower=upper, length=0.1,...){
>     if(length(x) != length(y) | length(y) !=length(lower) | length(lower)
> != length(upper))
>     stop("vectors must be same length")
>     arrows(x,y+upper, x, y-lower, angle=90, code=3, length=length, ...)
>     }
>
> Means<-tapply(data$IntercourseIntention,data$FilmAndOrder,mean)
> SDs<-tapply(data$IntercourseIntention,data$FilmAndOrder,sd)
> b<-barplot(Means,col=c("gray","tan1","blue","white"),axis.lty=1,ylim=c(2,3),names.arg=c("","","",""),ylab="Intercourse
> intention",xlab="Film and condition")
> legend("topleft",c("Pre drink, Neutral","Post drink, Neutral","Pre-drink,
> Sexual", "Post-drink, Sexual"),col=c("gray","tan1","blue","white"),pch=15)
> error.bar(b,Means, 1.96*SDs/10)
>
> (I know it's not pretty yet. To be fixed after the initial display is
> reasonable!) The y average value minimum truly is 1.2, but even ylim=c(1,X)
> produces this behavior of the bars running over the x-axis. I should be
> able to specify the starting value regardless of the range. Does anyone see
> the code bit I'm missing here?
>
> Much appreciated!
>
> Nikky
>
> ****************************
> Nicole Prause, PhD
> Research faculty
> Department of Psychiatry
> 760 Westwood Blvd
> University of California
> Los Angeles, CA 90024
> nprause@mednet.ucla.edu<mailto:nprause@mednet.ucla.edu>
> www.span-lab.com<http://www.span-lab.com>
>
> ________________________________
>
> IMPORTANT WARNING: This email (and any attachments) is o...{{dropped:12}}
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

