[R] Question about using “par”

Dieter Menne dieter.menne at menne-biomed.de
Thu Nov 29 15:35:56 CET 2007


cathelf <cathelf <at> hotmail.com> writes:

> Sorry for bothering your guys again. I am trying to use "par" to put 6
> figures into 3 rows and 2 columns. My code is:
> 
> op <- par(mfrow = c(1, 2))
> xyplot(x1+x2+x3 ~ y, data=resulta, type="l", pch=LETTERS[1:3], lty=c(1:3),
> main="For k=3, theata1=1")
> xyplot(x1+x2+x3  ~ y, data=resultb, type="l", pch=LETTERS[1:3], lty=c(1:3),
> main="For k=3, theata1=5")
....
>  
> But I can only get one figure in one page, not 6 figures in one page. Is
> there any other parameter I should specify? There is no error indicated.

Rule of thumb: what's documented under the header trellis or lattice does not
use par.

xyplot is a lattice/trellis function, which does not honor par(...) settings,
but uses package grid for layout and everthing else.

So either use standard plot 
  plot(rnorm(100),rnorm(100))

or do something like:

p = xyplot(whatever....)
print(p,split=c(1,1,2,2), more=TRUE)
p = xyplot(whoever,...
print(p,split=c(1,2,2,2), more=TRUE)

See print.trellis for details.

Dieter



More information about the R-help mailing list