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?
>
> Thanks
>
> John
John,
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.
For example:
png(file = "test%03d.png")
barplot(1:5)
barplot(1:10)
barplot(1:15)
dev.off()
You end up with three files named test001.png, test002.png and test003.png.
HTH,
Marc Schwartz