Hess, Stephane
2005-Mar-26 17:44 UTC
[R] Multi-plot figures with different numbers of plots in different rows
Dear all, I have 5 plots that I would like to include in a single figure, spread over two rows. If I use mfrow=c(2,3), and produce my plots one after the other, I will end up with three plots in the first row, and 2 in the second row, which is what I want. However, I would like the two plots in the second row to be moved to the centre of that row, rather than occupying the two left-most cells. I have also considered using split.screen, but this would mean that the plots in the lower half would be wider than in the upper half, whereas I want them all to be of the same size. Thanks in advance for any suggestions on how this can be done. Stephane -------------------------------------------------------------------------------------- Mr Stephane Hess Centre for Transport Studies Imperial College London -------------------------------------------------------------------------------------- [[alternative HTML version deleted]]
Federico Calboli
2005-Mar-26 17:56 UTC
[R] Multi-plot figures with different numbers of plots in different rows
On Sat, 2005-03-26 at 17:44 +0000, Hess, Stephane wrote:> Dear all, > > I have 5 plots that I would like to include in a single figure, spread over two rows. If I use mfrow=c(2,3), and produce my plots one after the other, I will end up with three plots in the first row, and 2 in the second row, which is what I want. However, I would like the two plots in the second row to be moved to the centre of that row, rather than occupying the two left-most cells. > > I have also considered using split.screen, but this would mean that the plots in the lower half would be wider than in the upper half, whereas I want them all to be of the same size. > > Thanks in advance for any suggestions on how this can be done.There is a book called `Gr?ficos Estad?sticos con R' under "contributed documentation" in the main R website. It should prove useful. The book is in spanish, but as it is a "graphical" manual, it should not matter much. If in troubles email me privately. Cheers, Federico -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com
Anne York
2005-Mar-26 18:20 UTC
[R] Multi-plot figures with different numbers of plots in different rows
On Sat, 26 Mar 2005, Hess, Stephane wrote: HS > Dear all, HS > HS > I have 5 plots that I would like to include in a single figure, spread over two rows. If I use mfrow=c(2,3), and produce my plots one after the other, I will end up with three plots in the first row, and 2 in the second row, which is what I want. However, I would like the two plots in the second row to be moved to the centre of that row, rather than occupying the two left-most cells. HS > HS > I have also considered using split.screen, but this would mean that the plots in the lower half would be wider than in the upper half, whereas I want them all to be of the same size. HS > HS > Thanks in advance for any suggestions on how this can be done. HS > HS > Stephane HS > HS > HS > -------------------------------------------------------------------------------------- HS > Mr Stephane Hess HS > Centre for Transport Studies HS > Imperial College London HS > -------------------------------------------------------------------------------------- Here is a brute force way: 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
Paul Murrell
2005-Mar-26 19:39 UTC
[R] Multi-plot figures with different numbers of plots in different rows
Hi Hess, Stephane wrote: > Dear all, > > I have 5 plots that I would like to include in a single figure, > spread over two rows. If I use mfrow=c(2,3), and produce my plots one > after the other, I will end up with three plots in the first row, and > 2 in the second row, which is what I want. However, I would like the > two plots in the second row to be moved to the centre of that row, > rather than occupying the two left-most cells. > > I have also considered using split.screen, but this would mean that > the plots in the lower half would be wider than in the upper half, > whereas I want them all to be of the same size. Something like ...? layout(rbind(c(1, 1, 2, 2, 3, 3), c(0, 4, 4, 5, 5, 0))) for (i in 1:5) { plot(i, type="n") text(1, i, paste("Plot", i), cex=4) } 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/