[R] How to save graphics in portable way in batch mode?
Chuck Cleland
ccleland at optonline.net
Thu Sep 30 15:06:03 CEST 2004
Have you considered the following approach to creating a single PDF
file with multiple pages of plots?
pdf(file="c:\\myfigs.pdf")
plot()
plot()
plot()
dev.off()
Or if you want a file for each figure with names generated
automatically, try something like:
pdf(onefile=FALSE)
plot()
plot()
plot()
dev.off()
It seems like as long as the PDF device is going to have the same
settings (e.g., width, height, and pointsize) across plots, there is no
need to call pdf() and dev.off() multiple times within a script.
hope this helps,
Chuck Cleland
Khamenia, Valery wrote:
> 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.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list