[R] plotting curve in xYplot -- using panel.curve
John Poulsen
jpoulsen at zoo.ufl.edu
Fri Jan 23 19:12:36 CET 2009
Hello,
I am trying to plot a curve over points plotted with se's in xYplot (see
example below). I can get Figure 1 below to plot the data with error.
However, I keep getting a the error message
"Error using packet 1 object "y" not found"
Can anyone see what I am doing wrong?
Thanks!
John
-------------------------------
a=0.002; b=31.7; c=0.51
sds=rep(c(0,3,5,10,20,50,200), each=3)
y1=c(0,0,0.16, 0, 0.33,0.5, 0.16, 0.83, 1.16, 0.67, 0.5, 1.16, 0.83,
2.33, 3.6, 5.5, 4.33, 1.16, 22, 13, 12)
lo=y1-0.1*y1
hi=y1+0.1*y1
# Figure 1
xYplot(Cbind(y1, lo, hi)~jitter(sds, amount=1),
method="bars",ylim=c(0,max(hi)+1),
ylab="Y", xlab="X")
# Figure 2
xYplot(Cbind(y1, lo, hi)~jitter(sds, amount=1),
method="bars",ylim=c(0,max(hi)+1),
ylab="Y", xlab="X",
panel=function(...){
panel.xYplot(x,y,...)
panel.number=panel.number()
panel.curve(curve(a*(x+c)/1+a*b*(x+c), from=0, type="l", lwd=2))
}
)
More information about the R-help
mailing list