Skip to content

Newbie mistakes saving images to files

5 messages · Rex C. Eastbourne, Henrik Bengtsson, jim holtman

#
?png says:

"If you plot more than one page on one of these devices and do not
include something like %d for the sequence number in file, the file
will contain the last page plotted."

meaning

png("foo%03d.png", width=300, height=300);
plot(1); plot(2); plot(3);
dev.off();

generates foo001.png, foo002.png, foo003.png.  Work from this example,
and figure out what's missing in your code.  Your custom plot
functions probably don't generate new plots per se.

Personally, I always make sure to do one explicit pair of png() and
dev.off() calls per plot/image file.  That always works and makes it
more clear what is generated.

/Henrik

On Thu, Jan 14, 2010 at 2:17 PM, Rex C. Eastbourne
<rex.eastbourne at gmail.com> wrote: