[R] save plot
Gavin Simpson
gavin.simpson at ucl.ac.uk
Sat Jul 17 19:32:19 CEST 2010
On Fri, 2010-07-16 at 11:17 -0400, linda.s wrote:
> I made a plot, but after I made a second plot, the previous plot was
> gone. How can I save all the plots in a file (I do not manually copy
> and paste them one by one)?
> Thanks.
> Linda
[I presume you addressed this to Duncan Murdoch for a good reason???]
Open a new device before plotting, do your plotting, close the device.
For example, using a PDF device via pdf():
pdf("my_plots.pdf", height = 8, width = 8, pointsize = 10,
version = "1.4", onefile = TRUE)
for(i in 1:10) {
y <- rnorm(100)
x <- rnorm(100)
plot(y ~ x)
}
dev.off()
The last line (dev.off() is very important as the file will not be valid
pdf without closing the device.
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list