layout.show()
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