R Resources‎ > ‎

Bivariate plots

This set of codes will produce a bivariate plot with standard errors for both the x and y axes.

xy.error.bars=function(x,y,xbar,ybar){
plot(x,y,pch=16,ylim=c(min(y-ybar),max(y+ybar)),
xlim=c(min(x-xbar),max(x+xbar)))
arrows(x,y-ybar,x,y+ybar,code=3,angle=90,length=0.1)
arrows(x-xbar,y,x+xbar,y,code=3,angle=90,length=0.1)}

#Here's a trial run:
x=rnorm(10,25,5)
y=rnorm(10,100,20)
xb=(runif(10)*5)
yb=runif(10)*20
xy.error.bars(x,y,xb,yb)



Comments