[R] Y-lim minimum overrun in barplot

David Carlson dcarlson at tamu.edu
Mon Jun 3 16:55:33 CEST 2013

I believe you are looking for the offset= parameter. Consider the

barplot(c(2, 3), ylim=c(1, 3))
barplot(c(2, 3), ylim=c(1, 3), offset=1)

David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Nicole Prause
Sent: Friday, May 31, 2013 11:31 AM
To: r-help at r-project.org
Subject: [R] Y-lim minimum overrun in barplot

The code below produces the plot hosted here:

    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,

intention",xlab="Film and condition")
legend("topleft",c("Pre drink, Neutral","Post drink,
Neutral","Pre-drink, Sexual", "Post-drink,
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!


Nicole Prause, PhD
Research faculty
Department of Psychiatry
760 Westwood Blvd
University of California
Los Angeles, CA 90024
nprause at mednet.ucla.edu<mailto:nprause at mednet.ucla.edu>


IMPORTANT WARNING: This email (and any attachments) is\ ...{{dropped:10}}

More information about the R-help mailing list