[R] creating a ps. file

Thomas Petzoldt petzoldt at rcs.urz.tu-dresden.de
Mon Mar 15 15:40:32 CET 2004


mike.campana at freesurf.ch wrote:

> Dear all
> 
> I wrote a routine. At the end of each cycle of the loop I would like to 
> save the result (plot) in a postcriptfile.
> Of course if I just use dev.print in the following way: 
> dev.print(device=postcript, 'c:/Rfigures/plot_1.ps")
> I overwrite my results with the second cycle of the loop. I suppose 
> there is a way to define the file name so that several plots are 
> created(plot_1,plot_2...).
> 
> Could you give me an advice? Thanks a lot

Hello,

if you use:

nruns <- 200

for(i in 1:nruns) {
   postscript(file=paste("plot_", i+1000, ".ps", sep=""))
   # some plotting commands here
   #
   dev.off()
}

then you get your files in a sortable order without too much string
manipulation. Of course, you can also use 10000 or whatever, if you want
more figures.

Thomas P.

Sorry: in the postscript() function the option is called "file" and not 
"filename" like in bmp() and png()




More information about the R-help mailing list