How to change current Plot Window Size (in R)

Tal Galili picture Tal Galili · Mar 2, 2010 · Viewed 79.7k times · Source

For example. Assume I do:

dev.new(width=5, height=4)
plot(1:20)

And now I wish to do

plot(1:40)

But I want a bigger window for it.

I would guess that the way to do it would be (assuming I don't want to open a new window) to do

plot(1:40, width=10, height=4)

Which of course doesn't work.

The only solution I see to it would be to turn off the window and start a new one. (Which will end my plotting history)

Is there a better way ?

Thanks.

Answer

pmr picture pmr · Mar 9, 2013

Some workaround could be rather than using dev.new() R function use this function which should work across platform :

 dev.new <- function(width = 7, height = 7) 
 { platform <- sessionInfo()$platform if (grepl("linux",platform)) 
 { x11(width=width, height=height) } 
 else if (grepl("pc",platform)) 
 { windows(width=width, height=height) } 
 else if (grepl("apple", platform)) 
 { quartz(width=width, height=height) } }