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
|