s-news
[Top] [All Lists]

Re: Windows line plotting

To: Thom Burnett <Thom.Burnett@cognigencorp.com>, S-News <s-news@lists.biostat.wustl.edu>
Subject: Re: Windows line plotting
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Wed, 27 Jul 2005 16:48:27 -0400
I would normally prepare a static plot with panel.superpose.

tmp <- data.frame(id=rep(1:4, c(3,3,3,3)),
                  x=rep(1:3,4),
                  y=rnorm(12))

xyplot(y ~ x, groups=id, data=tmp,
       type="l", panel=panel.superpose)


An interactive plot is trickier as we have to keep the par()$usr
from within trellis, not the one that appears after trellis is
complete.  Therefore we use the following:


## draw the plot AND keep the usr from inside trellis 
xyplot(y ~ x, groups=id, data=tmp,
       type="l",
       panel=function(...) {
         panel.superpose(...)
         assign("par.usr", par()$usr, frame=0)
       })

## assign usr to match what it was inside trellis
par(usr=par.usr)

identify(tmp$x, tmp$y)  ## now works
points(2,0) ## now works

<Prev in Thread] Current Thread [Next in Thread>