[ESS] Graphics in emacs window: how to copy R screen devices in non-interactive sessions (remotes)

Vitalie Spinu spinuvit at gmail.com
Tue Nov 19 01:50:43 CET 2013


Thanks for the idea. I tried it with png device and it doesn't produce
any intermediate plots.

   png("main.png")
   plot(1:3)
   t <- recordPlot(); png('dev1.png'); replayPlot(t); dev.off()
   abline(h = 2)
   t <- recordPlot(); png('dev2.png'); replayPlot(t); dev.off()
   dev.off()

First time I run it, it throws 

   Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 
     plot.new has not been called yet

This is with R3.0.1. 

  Vitalie
   
 >>> Gergely Daróczi on Tue, 19 Nov 2013 01:11:03 +0100 wrote:

 > Hi Vitalie,
 > what about calling "recordPlot" and then "replayPlot" after opening e.g. a "png"
 > device.

 > Quick demo:

 >> plot(1:3)
 >> t <- recordPlot(); png('dev1.png'); replayPlot(t); dev.off()
 > X11cairo 
 > 2 
 >> abline(h = 2)
 >> t <- recordPlot(); png('dev2.png'); replayPlot(t); dev.off()
 > X11cairo 
 > 2 

 > Best,
 > Gergely

 > On 19 November 2013 00:50, Vitalie Spinu <spinuvit at gmail.com> wrote:

 >     Hi Everybody,

 >     I would like to add "graphics-in-emacs-window" functionality to ESS in
 >     near future. The most straightforward way to do that is to save graphic
 >     images to a disc files.

 >     Unfortunately I couldn't figure how to save buffered R devices. With
 >     screen devices dev.print does the job, but as screen devices are not
 >     available on remotes, dev.print is out of option. I didn't have luck
 >     with dev.copy either.

 >     So I would really appreciate if someone can suggest a way to save an
 >     incomplete R plot into an image file. In other words: How to write a
 >     function "copyDev" such that the following code

 >     plot(1:3)
 >     copyDev("dev1.png")
 >     abline(h = 2)
 >     copyDev("dev2.png")

 >     would generate two plots. The current devise is "pdf" or "png" or some
 >     other non-screen device.

 >     Any other ideas of how to implement the R-graphics-in-emacs functionally
 >     are very much welcome.

 >     Thanks,

 >     Vitalie

 >     ______________________________________________
 >     ESS-help at r-project.org mailing list
 >     https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list