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
We need to know how you're doing this, with a minimal example that we can run. Most graphics devices accept a file or filename argument, so that's one way. If you're using the pdf device, multiple plots will create multiple pages in the final output.. 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 > > ______________________________________________ > 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.
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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 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 > > GI got the error:> 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()null device 1
On 17.07.2010 20:52, linda.s wrote:>> 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 > > I got the error: >> 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() > null device > 1 >Which error??? Everyting went fine, as far as I can see. Uwe Ligges> ______________________________________________ > 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.
> [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()Can I make a group of jpg instead of pdfs? Thanks. Linda
Yes, ?jpeg --- On Tue, 8/3/10, linda.s <samrobertsmith at gmail.com> wrote:> From: linda.s <samrobertsmith at gmail.com> > Subject: Re: [R] save plot > To: gavin.simpson at ucl.ac.uk > Cc: r-help at r-project.org > Received: Tuesday, August 3, 2010, 5:36 PM > > [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() > > Can I make a group of jpg instead of pdfs? > Thanks. > Linda > > ______________________________________________ > 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. >
Can I make a group of jpeg instead of pdfs? Thanks. Linda On Wed, Aug 4, 2010 at 6:47 AM, John Kane <jrkrideau at yahoo.ca> wrote:> Yes, ??jpeg > > --- On Tue, 8/3/10, linda.s <samrobertsmith at gmail.com> wrote: > >> From: linda.s <samrobertsmith at gmail.com> >> Subject: Re: [R] save plot >> To: gavin.simpson at ucl.ac.uk >> Cc: r-help at r-project.org >> Received: Tuesday, August 3, 2010, 5:36 PM >> > [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() >> >> Can I make a group of jpg instead of pdfs? >> Thanks. >> Linda >> >> ______________________________________________ >> 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. >> > > >
?jpeg On 04-Aug-10 14:28, linda.s wrote:> Can I make a group of jpeg instead of pdfs? > Thanks. > Linda > > On Wed, Aug 4, 2010 at 6:47 AM, John Kane<jrkrideau at yahoo.ca> wrote: >> Yes, ?jpeg >> >> --- On Tue, 8/3/10, linda.s<samrobertsmith at gmail.com> wrote: >> >>> From: linda.s<samrobertsmith at gmail.com> >>> Subject: Re: [R] save plot >>> To: gavin.simpson at ucl.ac.uk >>> Cc: r-help at r-project.org >>> Received: Tuesday, August 3, 2010, 5:36 PM >>>> [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() >>> Can I make a group of jpg instead of pdfs? >>> Thanks. >>> Linda >>> >>> ______________________________________________ >>> 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. >>> >> >> > ______________________________________________ > 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. >-- Alain Guillet Statistician and Computer Scientist SMCS - IMMAQ - Universit? catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50