Dear r-help, Please, be so kind, tell me what does mean the parameter of layout.show()? I use R 1.6.2... Windows NT 4.0 Unfortunately I cannot understand phrases from the help "n: number of figures to plot." what figures? "`layout.show(n)' plots (part of) the current layout, namely the outlines of the next `n' figures." what figures? what does 'next' mean? I'm still trying to draw a legend outside a graph :) layout(matrix(c(1:2))) creates a wonderful layout. calls to plot.formula(... lines(... points(... axis(1,at=c(1979:2002)); draw a beautiful graph. but call to layout.show(1) (or any other parameter instead of 1) destroys it. what should I say to the R to make it keep already drawn graphs and show a legend on the other "panel" of the layout? -- Best regards Wladimir Eremeev mailto:wl at eimb.ru =========================================================================Research Scientist Leninsky Prospect 33, Space Monitoring & Ecoinformation Systems Sector, Moscow, Russia, 119071, Institute of Ecology, Phone: (095) 135-9972; Russian Academy of Sciences Fax: (095) 954-5534
Hi layout.show() is only intended to be used to draw a diagram illustrating how the device is being split up into different figure regions by layout(). An example from help(layout) demonstrates what it does ... nf <- layout(matrix(c(1,1,0,2), 2, 2, byrow=TRUE), respect=TRUE) layout.show(nf) The "n" parameter says how many of the figure regions to draw *in the diagram*. So layout.show() is just there to help you to understand what layout() is doing. For drawing a legend outside a plot, perhaps the following example may help (it is a modification of one of the examples in help(legend)) ... x <- seq(-pi, pi, len = 65) # layout with two columns; second one is 3cm wide layout(matrix(1:2, ncol=2), widths=c(1, lcm(3))) # plot; goes in first column of layout plot(x, sin(x), type = "l", ylim = c(-1.2, 1.8), col = 3, lty = 2) points(x, cos(x), pch = 3, col = 4) lines(x, tan(x), type = "b", lty = 1, pch = 4, col = 6) title("legend(..., lty = c(2, -1, 1), pch = c(-1,3,4), merge=TRUE)", cex.main = 1.1) # legend (as separate plot); goes in second column of layout par(mar=c(5.1, 0, 4.1, 0)) plot.new() plot.window(0:1, 0:1) legend(0.5, 0.5, xjust=0.5, yjust=0.5, c("sin", "cos", "tan"), col = c(3, 4, 6), lty = c(2, -1, 1), pch = c(-1, 3, 4), merge = TRUE, bg = "gray90") par(mar=c(5.1, 4.1, 4.1, 2.1)) Hope that helps. Paul Wladimir Eremeev wrote:> Dear r-help, > > Please, be so kind, tell me what does mean the parameter of layout.show()? > I use R 1.6.2... Windows NT 4.0 > > Unfortunately I cannot understand phrases from the help > "n: number of figures to plot." > what figures? > > "`layout.show(n)' plots (part of) the current layout, namely the > outlines of the next `n' figures." > > what figures? > what does 'next' mean? > > I'm still trying to draw a legend outside a graph :) > > layout(matrix(c(1:2))) creates a wonderful layout. > > calls to > > plot.formula(... > lines(... > points(... > axis(1,at=c(1979:2002)); > > draw a beautiful graph. > > but call to > layout.show(1) (or any other parameter instead of 1) destroys it. > > what should I say to the R to make it keep already drawn graphs and > show a legend on the other "panel" of the layout?-- 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
You can partition the plotting region into an arrangement of smaller plotting regions using nf <- layout(...). This allows you to put several plots of different sizes on the same graph. Layout also allows you to control where the sub plots go. But it can be difficult to know if you have entered the correct parameters else the ordering or number of plots can be screwed up. layout.show(nf) shows you the locations where the 1st, 2nd, ... graph will be plotted. Not only is it a very handy check before you plot but you can reuse the same design if you plan on doing this repeatedly. Calling layout.show() AFTER plotting a graph will certainly destroy the previous plot. Try running the example in layout(). -----Original Message----- From: Wladimir Eremeev [mailto:wl at eimb.ru] Sent: Thursday, April 17, 2003 2:35 AM To: r-help at stat.math.ethz.ch Subject: [R] layout.show() Dear r-help, Please, be so kind, tell me what does mean the parameter of layout.show()? I use R 1.6.2... Windows NT 4.0 Unfortunately I cannot understand phrases from the help "n: number of figures to plot." what figures? "`layout.show(n)' plots (part of) the current layout, namely the outlines of the next `n' figures." what figures? what does 'next' mean? I'm still trying to draw a legend outside a graph :) layout(matrix(c(1:2))) creates a wonderful layout. calls to plot.formula(... lines(... points(... axis(1,at=c(1979:2002)); draw a beautiful graph. but call to layout.show(1) (or any other parameter instead of 1) destroys it. what should I say to the R to make it keep already drawn graphs and show a legend on the other "panel" of the layout? -- Best regards Wladimir Eremeev mailto:wl at eimb.ru ========================================================================Research Scientist Leninsky Prospect 33, Space Monitoring & Ecoinformation Systems Sector, Moscow, Russia, 119071, Institute of Ecology, Phone: (095) 135-9972; Russian Academy of Sciences Fax: (095) 954-5534 ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help