[R] Returning to normal after call to layout()

Brian D Ripley ripley at stats.ox.ac.uk
Fri Dec 10 13:44:36 CET 2004

On Fri, 10 Dec 2004, michael watson (IAH-C) wrote:

> Hi Petr
> Yes thanks I did get your response and it was helpful.  However, I have
> now resorted to using barplot() to draw a legend (as all I wanted was
> colored boxes and text) and it works very well for my needs.
> Basically, with layout() I'm not getting what I would expect, which may
> be a problem with my expectation rather than anything else.  Like I say,
> I have a function which draws a plot, using layout to divide the
> plotting region into top and bottom.  Fine.  If the user calls my
> function, and then another plotting function, I would expect the new
> plotting function to overwrite the whole of the old plot - but it
> doesn't, it draws the new plot in the top half of the old plot, and
> clears the bottom plot.  So what I want is something which says, after
> calling layout(), "OK, I'm done plotting in two different regions, I
> want you to treat the current device as a single region again".

Please look at the example in ?layout, which does exactly that.
Or look at ?par, especially mfrow and mfcol.  You need to reset the
appropriate par()s.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list