[R] Multi-plot figures with different numbers of plots indifferentrows

Earl F. Glynn efg at stowers-institute.org
Wed Mar 30 00:59:58 CEST 2005


"Paul Murrell" <p.murrell at auckland.ac.nz> wrote in message
news:<4249D8B7.9070702 at stat.auckland.ac.nz>...
> Does this do what you want?
>
> layout(rbind(c(1, 2, 3),
>               c(0, 4, 0)))
> plot(1:10, main="Plot 1")
> plot(1:20, main="Plot 2")
> plot(1:30, main="Plot 3")
> plot(1:40, main="Plot 4")
> # new page!
> plot(1:40, main="Plot 5")

Yes, that works nicely.  Thank you very much.

I tried this wrapped with a pdf/dev.off and it works great:

pdf("test.pdf")
  <plot statements here>
dev.off()

I guess I should always use layout and avoid using mfrow or mfcol, since
it's more flexible in general.

I can't decide if the existing behavio(u)r of mfrow/mfcol is a "bug" or a
"feature" when some plots are to be left blank, and one wants to advance to
the next figure.  With your solution, I won't need to care <g>.  Thanks.

efg




More information about the R-help mailing list