[R] layout problem

Matt Pocernich pocernic at rap.ucar.edu
Fri Jun 6 18:28:09 CEST 2003


Hello,

I have a question about using the layout command within a function.  I've
written function that uses layout to create a figure from 2 plots.  This
works fine to create a figure.  When I use par(mfrow = c(2,2)) to create multiple
 plots, it seems that the layout command resets the mfrow parmeter.
Is there a way for me to avoid this problem?

For example

practice<- function() {
op<- par(oma=c(3,3,5,4))
nn<- layout(matrix(c(0,1), nrow = 1), widths = c(1,4))
plot(0,0)
mtext("Sample graph", outer = TRUE, line = 1, cex = 2)

par(op)
}

practice() # works fine.

par(mfrow = c(2,2))

practice()
practice()
practice()
practice()

## produces 4 graphs on seperate pages.

Thanks.

Matt

Matt Pocernich
NCAR - Research Applications Program
303-497-8312




More information about the R-help mailing list