[R] Multi-plot figures with different numbers of plots indifferent rows
Paul Murrell
p.murrell at auckland.ac.nz
Wed Mar 30 00:37:43 CEST 2005
Hi
Earl F. Glynn wrote:
> "Anne York" <york at zipcon.net> wrote in message
> news:Pine.LNX.4.62.0503261316330.2758 at sasquatch...
>
>
>>par(mfrow=c(2,3)) #set up 2 rows x 3 colums
>>plot(1:10) #plot 1
>>plot(1:10) #plot 2
>>plot(1:10) #plot 3
>>par(mfg=c(2,2)) # start next plot at 2,2 instead of 2,1
>> plot(1:10) # 4th plot
>
>
> If you want to leave the last plot(s) in a such a figure blank,
> and continue on with another figure, how does that work?
>
> For example:
>
> par(mfrow=c(2,3)) #set up 2 rows x 3 columns
> plot(1:10, main="Plot 1")
> plot(1:20, main="Plot 2")
> plot(1:30, main="Plot 3")
> par(mfg=c(2,2)) # start next plot at 2,2 instead of 2,1
> plot(1:40, main="Plot 4")
>
> # What if 5th plot is to start on next page?
> # Why do plots 5 and 6 overlay plots 1 and 2 instead
> # of being on a new page?
> par(mfg=c(1,1))
> plot(1:50, main="Plot 5")
> plot(1:60, main="Plot 6")
>
> If "par(mfg=c(1,1))" is left out, Plot 6 is on the next figure.
>
> The "new=T" parameters seems like a possible solution, but gives this
> warning and is ignored:
> Warning messages:
> 1: parameter "new" couldn't be set in high-level plot() function
>
> par(mfrow=c(2,3)) #set up 2 rows x 3 columns
> plot(1:10, main="Plot 1", new=T)
> plot(1:20, main="Plot 2")
> plot(1:30, main="Plot 3")
> par(mfg=c(2,2)) # start next plot at 2,2 instead of 2,1
> plot(1:40, main="Plot 4")
>
> # What if 5th plot is to start on next page?
> # Why do plots 5 and 6 overlay plots 1 and 2 instead
> # of being on a new page?
> par(mfg=c(1,1))
> plot(1:50, main="Plot 5", new=T)
> plot(1:60, main="Plot 6")
>
> How do I create a series of plots in one figure and control
> when a new figure is created? (without using dummy blank placeholder plots)
>
> The example above is only for discussion. I really want to do this in a
> loop
> and create 5 plots per figure, and repeat this for many pages in a PDF file.
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")
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list