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
> 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?As far as I understand that is not possible, since "`layout' divides the device up", not a part of the device. If you need to split your device again and again, you should package grid (or lattice, on a higher level); these allow to do so. However, these need different plot commands, i.e. plot() will not work with them HTH Thomas --- Thomas Hotz Research Associate in Medical Statistics University of Leicester United Kingdom Department of Epidemiology and Public Health 22-28 Princess Road West Leicester LE1 6TP Tel +44 116 252-5410 Fax +44 116 252-5423 Division of Medicine for the Elderly Department of Medicine The Glenfield Hospital Leicester LE3 9QP Tel +44 116 256-3643 Fax +44 116 232-2976