10

When using R within an interactive windowing system (such as Windows, Ubuntu, MacOSX) the default behaviour for plot(x) is to open an interactive graphics device (with plot.new() under the hood), and draw stuff on it. The device can be interactively moved, resize and closed, and (depending on the platform) presents other GUI-based operations. It can be closed or copied with R code, with dev.off(), dev.copy() and there are other functions in the family.

Can the device be moved or resized using R code?

I realize that this question may have many platform-specific answers, and all and any detail is welcome. I am most interested in the default Windows install options for the latest version of R, but keen to learn more about the differences between OS environments and other options.

mdsumner
  • 29,099
  • 6
  • 83
  • 91

3 Answers3

5

If you really wanted to do this, you could use the GTK libraries and the cairoDevice package. Then you can resize things with RGtk2 calls. It isn't the default install, but is cross platform.

library(RGtk2)
library(cairoDevice)
w = gtkWindow()
da <- gtkDrawingArea()
asCairoDevice(da)
w <- gtkWindow(show=FALSE)
w$add(da)
w$show()
hist(rnorm(100))
w$resize(500, 500)
w$move(200,200)
jverzani
  • 5,600
  • 2
  • 21
  • 17
4

A collection of past attempts with few answers but possibly useful:

Community
  • 1
  • 1
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • I wonder if anyone has tried to compile all (or choice bits) of BDR snark in one place. Might make for some amusing reading. – joran Jun 03 '11 at 17:18
3

Have you look at the excellent packages by Felix Andrews which bring much interactivity to lattice devices:

If your question is about the physical size of the window on the screen: I don't think so. That is a window manager task, and you would have to write (very platform dependent, I suspect) code to alter the window once drawn.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725