[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 13:52:48 CET 2010
On Wed, 3 Mar 2010, Tal Galili wrote:
> BTW,If someone is willing to help with two questions - we can extend the
> small code I just wrote to other OS's. It might be useful for future people
> who will present R graphical outputs to an audience.
But none of the other standard devices supports recording.
> The questions are:
> 1) What is the equivalent of the command "windows" to other OS ?
X11() or quartz(), but see options('device'), and e.g. under JGR
(some) people prefer JavaGD ... and so on.
Usually dev.new() is fine: I think your error was to use 'T' when I
wrote 'TRUE'.
> 2) How can you get from R what OS is running it ?
> I try
> sessionInfo()$R.version$os
> but it gives me:
> "mingw32"
> Which I am not sure how to connect between this and "windows XP"...
Why do you think there is a connection?
>
>
>
> 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 2:00 PM, Tal Galili <tal.galili at gmail.com> wrote:
> Thanks Brian,I wrote a tiny script employing your answer.
>
> resize.win <- function(Width=6, Height=6)
> {
> # works for windows
> dev.off(); # dev.new(width=6, height=6)
> windows(record=TRUE, width=Width, height=Height)
> }
> resize.win(5,5)
> plot(rnorm(100))
> resize.win(10,10)
> plot(rnorm(100))
>
>
>
> Best,
> 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 12:13 PM, Prof Brian Ripley
> <ripley at stats.ox.ac.uk> wrote:
> 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
>
>
>
>
>
--
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