Thursday, August 16, 2012

Plotting error bars in two dimensions

This came up today in a conversation with a postdoc in my lab, Graham Reynolds.

There are probably more elegant ways to do this, but one simple solution for plotting error bars in two dimensions is provided by just calling the gplots function plotCI twice. Here's an example:

# simulate data
x<-rnorm(n=5,mean=4); y<-rnorm(n=5,mean=4)
# here is a completely arbitrary simulation model
# for the standard error/deviation
SDx<-runif(5,0.1,1); SDy<-runif(5,0.1,1)
# plot
# first get the limits for x & y +- error
# now plot twice, remember to set add=TRUE

The result is not too bad:
There must be a function that automates this. If you know which one - please feel free to post it in "comments."


  1. Huh. I always just used arrows() to do this...


Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.