[R] Change current plot window size. Or - saving/loading current device plotting history

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 3 11:13:03 CET 2010


On Wed, 3 Mar 2010, Tal Galili wrote:

> Thanks for replying Brian.
> Indeed, I am working on windows (XP).
> 
> I tried doing:
> dev.new(record = T)
> And got:
> Warning message:
> ‘mode(record)’ differs between new and previous
>          ==> NOT changing ‘record’ 
> 
> But if I understood you, I could open a window with a plot, then open a new
> one (with different dimensions), and then close the old plot device, while
> still keeping all my record. Did I get this correctly ?

Yes: it worked for me when I tried it.

> (if so, I would love a simple example of how that can be done using the
> record = T)

It is windows() and not dev.new() that you need to call with 
record=TRUE.

> Thank you very much!
> 
> Tal
> 
> 
> 
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> ---------------------------------------------------------------------------
> -------------------
> 
> 
> 
> 
> On Wed, Mar 3, 2010 at 11:48 AM, Prof Brian Ripley <ripley at stats.ox.ac.uk>
> wrote:
>       You haven't mentioned an OS nor a graphics device, So I will
>       guess Windows and windows(), since that is commonest device with
>       a history.
>
>       On Wed, 3 Mar 2010, Tal Galili wrote:
>
>             Hello dear R-help members,
>
>             Very soon I am to give a lecture on R. And in that
>             lecture I intend to move
>             between: par(mfrow = c(1,1)) to par(mfrow = c(1,2))
>             back and forth.
>             I anticipate this will damage the image proportions
>             and will force me to
>             resize the window.
>             So far I have found it is possible to close the
>             window and then reopen it
>             (bigger/smaller) by using:
> 
>
>             dev.off()dev.new(width=5, height=4)plot(1:20)
> 
>
>             The issue with this solution is that I loose all the
>             history I had with
>             these windows.
>
>             Thus, my question is either of two:
>             1) Can I resize a plot window AFTER it was created ?
> 
> 
> Not programmatically.  But you can have more than one device open and
> switch between them by dev.next/dev.set ....
>
>       2) can you save and load a plot history, for between
>       closing and opening a
>       graphic device ?
> 
> 
> Yes, from the menu.  There is also the more general
> recordPlot/replayPlot mechanism.
> 
> But note that the windows() plot history is shared between devices, so
> if you work with multiple windows their histories will be interleaved.
> It is a history _of the session_ and so you can page back into the
> history of previously opened devices.
> 
> So I would do this by opening a device with record = TRUE, and when I
> needed a different aspect ratio, open one with record = FALSE and
> close it when I was done with it.
> 
>
>       Thanks for any help,
>       Tal
>
>       ----------------Contact
>       Details:-------------------------------------------------------
>       Contact me: Tal.Galili at gmail.com |  972-52-7275845
>       Read me: www.talgalili.com (Hebrew) |
>       www.biostatistics.co.il (Hebrew) |
>       www.r-statistics.com (English)
> ---------------------------------------------------------------------------
>       -------------------
> 
> 
> --
> 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
> 
> 
> 
>

-- 
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