p.murrell at auckland.ac.nz
Thu Apr 17 01:05:45 CEST 2003
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)
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
# 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))
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.
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
> 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
64 9 3737599 x85392
paul at stat.auckland.ac.nz
More information about the R-help