[R] How to save graphics in portable way in batch mode?

Khamenia, Valery V.Khamenia at biovision-discovery.de
Thu Sep 30 14:47:19 CEST 2004


Hi all,

What is the right portable way to save graphics 
in batch mode?

Remarks:

  1. Problem is STFWed and RTFMed. In particular a short note 
     about png() is found in R-FAQ. In fact, there were stated 
     that png() is not reliable under Linux in batch mode.

  2. savePlot under windows is quite convenient, but 
     not supplied under Linux.

  3. pdf() + postscript() < savePlot()
     Indeed, savePlot does support much more image formats 
     and is flexible in changing type of output via its
     argument.

  4. The scheme 

     "postscript(); plot(); dev.off();" 

     makes R-scripts not really nice. Indeed, if one's script 
     had about 15 plot calls then in order to save graphics 
     one need to add 15 times the postscript() in prior of 
     plot() call and then 15 times the dev.off() as epilogue 
     to plot() call.

  5. Hm, one could create function similar to Sweave() 
     (see R-1.9.1\src\library\utils\R\Sweave.R) and 
     benefit from automatic name generation and saving.
     But it is quite unnatural, isn't it?
      
so, it would be nice to know what is the "right way".

P.S. BTW, will be there any specific changes in R-2.x?

Thank you a priori for your comments,
Valery.




More information about the R-help mailing list