[R] par(new=T) with xyplot
p.murrell at auckland.ac.nz
Thu Jun 6 01:59:59 CEST 2002
> I know I should not mix base plotting functions with grid/lattice functions,
> but I have used a "quick-and-dirty" trick of par(new=T) in the past for
> annotating a trellis-drawn graph in various versions of S-PLUS. The
> sequence goes something like this:
> > windows(width = 5, height = 5, pointsize = 10) # open up the device
> > xyplot(y ~ x)
> > par(new=T)
> > xyplot(y2 ~ x)
> > par(new=F)
> Using R 1.5.0 in Windows, I tried this for the first time today, and the
> par(new=T) setting appears to be ignored by the second xyplot call; i.e.,
> the frame is cleaned and only the second printing of xyplot appears on the
> device. (If instead of the second xyplot I use a base plot function like
> plot.default, the frame is not cleaned, which I want to happen).
> Is there anything analogous to par(new=T) that I could use to achieve this
> behavior of "not cleaning the frame" with lattice commands? Any workaround
> or advice is appreciated.
You can use the "more" argument to the print.trellis() function. For
x <- rnorm(10)
y <- rnorm(10)
y2 <- rep(0, 10)
p1 <- xyplot(y ~ x, ylim=c(-5, 5))
p2 <- xyplot(y2 ~ x, pch=16, ylim=c(-5, 5), ylab=" ")
bg <- trellis.par.get("background")
bg$col <- "transparent"
... NOTE the need to set the background to "transparent" before doing
the second plot.
Hope that helps
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help