[R] plotting curve in xYplot -- using panel.curve

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Jan 24 01:29:18 CET 2009


On Fri, Jan 23, 2009 at 12:46 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
>
>
>
> John Poulsen wrote:
>>
>> 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))
>>         }
>>          )
>>
>>
> John Poulsen <jpoulsen <at> zoo.ufl.edu> writes:
>
>> 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"
>> -------------------------------
>>
>>  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 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))
>>         }
>>          )
>>
>
>
> Try
>   panel=function(x,y,...){
>
> Looks like it is not exactly what you expected, but the error is gone.

Also, this line doesn't make sense:

panel.curve(curve(a*(x+c)/1+a*b*(x+c), from=0, type="l", lwd=2))

You probably want

panel.curve(a*(x+c)/1+a*b*(x+c), from=0, type="l", lwd=2)

-Deepayan




More information about the R-help mailing list