[R] How do I change which R Graphics Device is active?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Jun 30 18:48:15 CEST 2009


On Tue, Jun 30, 2009 at 5:15 PM, milton ruser<milton.ruser at gmail.com> wrote:
> How about:
>
> dev.cur()
> dev.list()
> dev.next(which = dev.cur())
> dev.prev(which = dev.cur())
> dev.off(which = dev.cur())
> dev.set(which = dev.next())
> dev.new(...)
> graphics.off()
> dev.cur()
> dev.list()
> dev.next(which = dev.cur())
> dev.prev(which = dev.cur())
> dev.off(which = dev.cur())
> dev.set(which = dev.next())
> dev.new(...)
> graphics.off()
> :-) bests
>

 To keep track, call dev.cur() after creating a new plot and assign it
to something memorable. Here's how to keep a histogram and an xy plot:

> dev.new();histPlot = dev.cur()
> dev.new();xyPlot = dev.cur()
> dev.set(histPlot);hist(runif(100))
X11cairo
       2
> dev.set(xyPlot);plot(1:10)
X11cairo
       3

 You just have to remember to call dev.set before your particular plot.


Barry




More information about the R-help mailing list