[R] multiple pages of plot in one image file
marc_schwartz at me.com
Mon May 24 22:02:00 CEST 2010
On May 24, 2010, at 2:32 PM, array chip wrote:
> Hi, is there a way to create one image file (like using win.metafile(), bmp(), etc) that contained multiple pages of plots, just like what postscript() does in creating PDF file?
There is no notion of pages with bitmapped graphics as there is with PDF/PS, where you can have multiple separate plots in a single file. The single bitmapped file is designed to be rendered on a single bitmapped display device. The EMF/WMF metafiles on Windows are, I believe, subject to the same limitations, even though they are vector based.
However, you can output multiple plots to multiple files (one-to-one) after a single call to one of the bitmapped device functions. See the 'filename' argument in the various functions (eg. ?png) where you can use a filename format that includes a sprintf style integer format, such as "MyPlots%03d.png". The "%03d" will start as '001' and increment with each new plot() call before the subsequent dev.off() call.
png(file = "test%03d.png")
You end up with three files named test001.png, test002.png and test003.png.
More information about the R-help