[R] multiple plots without for loops

Petr PIKAL petr.pikal at precheza.cz
Wed Jun 16 09:50:38 CEST 2010


Hi

I use an option with PDF, which can have multi page output. You can

pdf("some_graphs.pdf")

# do all your plotting let say in cycle something like

for( i in 1:n) plot(something[,1], something[,i+1], ...)

dev.off()

You will get one multipage pdf document in working directory which you can 
get through and delete if you do not want it.

Regards
Petr



r-help-bounces at r-project.org napsal dne 16.06.2010 06:05:22:

> Beautiful!  Thanks Peter and Phil for your kind help-
> 
> sherri
> 
> 
> Quoting Peter Alspach <Peter.Alspach at plantandfood.co.nz>:
> 
> > Tena koe Sherri
> >
> > You could turn on graphics recording (if you are using Windows click
> > History on the graphics window and choose recording).  Then you can 
page
> > up/down to view them.  If you save.image on exit, you'll probably want
> > to rm(.SavedPlots) (I think that's the correct name.  ls(all=TRUE) 
will
> > confirm it) first.
> >
> > HTH .......
> >
> > Peter Alspach
> >
> >> -----Original Message-----
> >> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> >> project.org] On Behalf Of sheck at ucar.edu
> >> Sent: Wednesday, 16 June 2010 3:27 p.m.
> >> To: Phil Spector
> >> Cc: r-help at r-project.org
> >> Subject: Re: [R] multiple plots without for loops
> >>
> >> Thanks for the reply, Phil.
> >>
> >> My computer gets hung up on the par(ask=TRUE) call.  I just tried
> >>
> >> readline("Hit <ENTER> to proceed.")
> >>
> >> and, it works well going forward. However, I cannot go backwards. Any
> >> thoughts?
> >>
> >> thanks again-
> >>
> >> sherri
> >>
> >> Quoting Phil Spector <spector at stat.berkeley.edu>:
> >>
> >> > Sherri -
> >> >     Perhaps calling
> >> >
> >> > par(ask=TRUE)
> >> >
> >> > before plotting would be useful.  (You'll be prompted to
> >> > hit Return to see the next plot in the series.)
> >> >
> >> >                 - Phil Spector
> >> >                  Statistical Computing Facility
> >> >                  Department of Statistics
> >> >                  UC Berkeley
> >> >                  spector at stat.berkeley.edu
> >> >
> >> >
> >> > On Tue, 15 Jun 2010, sheck at ucar.edu wrote:
> >> >
> >> >> Dear All-
> >> >>
> >> >> I am trying to plot over one hundred figures.  I do not want to
> > save
> >> >> them, just walk through them to take a look.  If I run the code as
> >> >> it is below, then the plots just rapidly run through.  I tried
> >> >> adding a new device, but I reached the device number limit.  I 
have
> >> >> gone through the online manuals, done google searches  and the R
> >> >> Site help pages and haven't found anything to help me. any 
thoughts
> >> >> or just pointing me to the right place would be great! I feel like
> >> >> this should be simple!
> >> >>
> >> >> invisible(lapply(split(agg$mph, breaks), function(.values){
> >> >>    #x11()
> >> >>    #par(mfrow=c(4, 4))
> >> >>    plot(.values)
> >> >> } ))
> >> >>
> >> >>
> >> >> Thanks in advance for any guidance,
> >> >>
> >> >> Sherri Heck
> >> >>
> >> >> ______________________________________________
> >> >> 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.
> >
> 
> ______________________________________________
> 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.



More information about the R-help mailing list