[R] Manage several graphical devices in interactive mode

(Ted Harding) Ted.Harding at manchester.ac.uk
Sun Jul 25 16:03:18 CEST 2010


On 25-Jul-10 13:22:11, Sébastien Bihorel wrote:
> Dear R-users,
> 
> Does anybody know a good way to create and use several graphical
> devices at the same time in interactive mode? Ideally, I'd like
> to open 2 to 3 devices and assign names to them. This way, I could
> make any addition/modification/update to a particular device using
> its name.
> 
> I did not see anything like a name argument in ?X11. Is there an
> alternative?
> 
> Thanks in advance for your feeback.
> Sebastien

You can certainly do this "by hand". The basic R terminal is device
number 1. If you do X11() (or invoke it implicitly by using a 'plot'
command) this will be device number 2. With just this one open, any
'plot' (or plot-related) commands will re-use it.

However, having opened device #2, you can do X11() again and get a
second graphics device which will be number 3. And so on, for as many
additional devices as you like.

By default, the device that the results of any 'plot' command are
sent to will be the most recently opened one. However, you can select
the device using the command dev.set(n) where n ( = 2,3,... ) is the
device you want to use. The device which is "active" will be shown
by the word "(ACTIVE)" attached to its display. All other devices
will show "(inactive)".

You could "name" your devices by indexing a vector (2:n) by names.

Try the following, Starting with no graphics devices open:

X11()  # dev 2
X11()  # dev 3
X11()  # dev 4  ## This one is currently active
       ## Arange these so that you can see all their top bars
devN <- c(plotA=2,plotB=3,plotC=4)

dev.set(devN["plotA"])  # dev 2 is active

dev.set(devN["plotC"])  # dev 4 is active

dev.set(devN["plotB"])  # dev 3 is active

dev.set(devN["plotA"])  # dev 2 is active

dev.set(devN["plotC"])  # dev 4 is active

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 25-Jul-10                                       Time: 15:03:14
------------------------------ XFMail ------------------------------



More information about the R-help mailing list