[R] how to plot and save plots in batch mode

From: Kinoko <andzsinszan_at_gmail.com>
Date: Tue, 25 Nov 2008 02:11:44 -0800 (PST)

Dear list,

This is not a question but a rather short note how to save a plot if it was created in batch mode.
It took me like 2 hours to figure it out, I hope it can save time for those who - like me - are not really fast in picking up diosyncrasies of R. (as far as I remember I had no problems whatsoever batch plotting in
gnuplot, matplotlib, matlab... )

The problem I had was that while I could plot and save my data using RGui,
the same script did not work in batch mode.

plot(x,y, bla-bla... )
dev.set (2)
dev.print (device=png, file=outFile, bla-bla)

But this does not work in BATCH mode.
The error msg is:
"... can only print from a screen device" Sure, the plotting window does not pop up in batch mode.

What I had to do was to to put a command:


before starting the plot. Now I can save my plots in batch mode

Well, I am more than sure, that there are more elegant solutions without invoking the window...

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 25 Nov 2008 - 10:15:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Nov 2008 - 16:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive