I would like to plot lots of plots (2x2 plots) of a set of data for many sets. I can do it just fine for one set of data, but I would like to generate a small mountain of plots for others to examine. Basically, I would like to generate the same par( mcol=c(2,2) ) plot for about 1000 datasets. I've been iterating through them in the plot window, but I would like to send all the plots to a eps file and plot the eps file (or bring the thing into a latex doc and generate the pdf which I can do no problem. I don't knwo who many datasets I will have and may and I think I'll just have to create one file for each plot into a dir and somehow bring all the plots in the dir into a document. Has anyone any suggestions for this task? Thanks, Jeff. Jeff D. Hamann Hamann, Donald & Associates PO Box 1421 Corvallis, Oregon 97339 jeff_hamann at hamanndonald.com www.hamanndonald.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I believe you can send multiple plots to a pdf file by leaving the pdf() device open. By default, each new plot will be put on a different page in the pdf file. So, pdf(file="lotsofplots.pdf") par(mfcol=c(2,2)) plot(x1,y1) plot(x2,y2) plot(x3,y3) dev.off() The file 'lotsofplots.pdf' should have three pages. However, I remember reading on this list somewhere that there's a hard limit of 512 pages to a file, but I'm not 100% sure. You may have to use one or two files, depending on the number of datasets you're plotting. But I suppose that's better than 1000 files. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Wed, 22 May 2002, Jeff D. Hamann wrote:> I would like to plot lots of plots (2x2 plots) of a set of data for many > sets. I can do it just fine for one set of data, but I would like to > generate a small mountain of plots for others to examine. Basically, I would > like to generate the same par( mcol=c(2,2) ) plot for about 1000 datasets. > I've been iterating through them in the plot window, but I would like to > send all the plots to a eps file and plot the eps file (or bring the thing > into a latex doc and generate the pdf which I can do no problem. I don't > knwo who many datasets I will have and may and I think I'll just have to > create one file for each plot into a dir and somehow bring all the plots in > the dir into a document. Has anyone any suggestions for this task? > > > Thanks, > Jeff. > > > Jeff D. Hamann > Hamann, Donald & Associates > PO Box 1421 > Corvallis, Oregon 97339 > jeff_hamann at hamanndonald.com > www.hamanndonald.com > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I would like to plot lots of plots (2x2 plots) of a set of data for many > sets. I can do it just fine for one set of data, but I would like to > generate a small mountain of plots for others to examine. Basically, I would > like to generate the same par( mcol=c(2,2) ) plot for about 1000 datasets.I do exactly this with Sweave(), where dozens of reports are run nightly that number into the hundreds of pages per report. library(tools) help(Sweave) and... http://www.ci.tuwien.ac.at/~leisch/Sweave/ (Free advice - if you're going to do 1000s of plots per run, and you're not familiar with try(), get familiar it, to avoid Great Anguish <tm>). I do this by making a temporary directory, loop over a list of report titles, and have Sweave() produce a separate report for each into that temporary directory (you wind up with lots of self-contained .tex files). I then run a perl script over every .tex file in the directory, collating them into one big .tex file. The perl script is really quite simple (see below). A good perl hacker could do a much better job; I still program perl like a mediocre C hacker. Sweave produces eps and pdf versions of the plots, so running pdflatex directly is also an option, rather than LaTeX + eps -> dvi + dvipdfm -> pdf. Sweave is a very, very good utility. It's an amazing combination - typesetting by LaTeX, and calculations and graphics by R, handled seamlessly together, usually while I'm alseep, as the reports are run overnight. Thanks, Fredrich! Cheers Jason collate.pl: #!/usr/bin/perl -w # ########################## # collate.pl ############# # # DESCRIPTION ############ # Take multiple LaTeX files, and combine them into one. # Assume that the first preamble is identical throughout. # # On the first file, everything is printed, except the # \end{document}. # # After the first file is read, only the portions # between \begin{document} and \end{document} # are printed. \tableofcontents and \listoffigures # are also omitted from subsequent files. # # ARGUMENTS ############## # 1..n) files to collate. reads from stdin if none specified. # my $printThis = 1; #true if we're to print the preamble my $toc = 0; #true if we've already printed \tableofcontents my $lof = 0; #true if we've already printed \listoffigures while(<>){ if($toc && $_ =~ /\\tableofcontents/) { $_ =~ s/\\tableofcontents//; } if($lof && $_ =~ /\\listoffigures/) { $_ =~ s/\\listoffigures//; } if(!$printThis) { if($_ =~ m/\\begin{document}/) { $_ =~ s/\\begin{document}//; $printThis = 1; } } if($printThis) { #if we're on the first file if($_ !~ /\\end{document}/ ) { #print all lines that don't print; #contain \end{document} } else { print; #if they do, strip out \end{document} $printThis = 0; } } if($_ =~ /\\tableofcontents/) { $toc = 1; } if($_ =~ /\\listoffigures/) { $lof = 1; } } print "\\end{document}\n"; -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > I believe you can send multiple plots to a pdf file by leaving the pdf() > > device open. By default, each new plot will be put on a different page in > > the pdf file.> ah-ha! had I only known. I forgot to check the other devices supported. > Works like a charm on windows too! Saaaweet!Careful - this will choke at 501 plots. help(pdf) .. There is an internal limit of 500 pages per PDF file, which should be ample. .. If you really want to do 1000 plots, you need a Plan B. Cheers Jason -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
yes. in this case a plan b might be in order... thanks. ----- Original Message ----- From: <jasont at indigoindustrial.co.nz> To: "Jeff D. Hamann" <jeff_hamann at hamanndonald.com>; "Roger Peng" <rpeng at stat.ucla.edu>; <r-help at stat.math.ethz.ch> Cc: <r-help at r-project.org> Sent: Wednesday, May 22, 2002 4:34 PM Subject: Re: [R] plotting a 1000 plots?> > > I believe you can send multiple plots to a pdf file by leaving thepdf()> > > device open. By default, each new plot will be put on a differentpage in> > > the pdf file. > > > ah-ha! had I only known. I forgot to check the other devices supported. > > Works like a charm on windows too! Saaaweet! > > Careful - this will choke at 501 plots. > > help(pdf) > .. > There is an internal limit of 500 pages per PDF file, which should > be ample. > .. > > If you really want to do 1000 plots, you need a Plan B. > > Cheers > > Jason > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Just use a current version of R: NEWS for 1.5.0 says: o The pdf() device was running out of objects before the documented 500 page limit. Now there is no limit. On Wed, 22 May 2002, Jeff D. Hamann wrote:> yes. in this case a plan b might be in order... > > thanks. > > ----- Original Message ----- > From: <jasont at indigoindustrial.co.nz> > To: "Jeff D. Hamann" <jeff_hamann at hamanndonald.com>; "Roger Peng" > <rpeng at stat.ucla.edu>; <r-help at stat.math.ethz.ch> > Cc: <r-help at r-project.org> > Sent: Wednesday, May 22, 2002 4:34 PM > Subject: Re: [R] plotting a 1000 plots? > > > > > > I believe you can send multiple plots to a pdf file by leaving the > pdf() > > > > device open. By default, each new plot will be put on a different > page in > > > > the pdf file. > > > > > ah-ha! had I only known. I forgot to check the other devices supported. > > > Works like a charm on windows too! Saaaweet! > > > > Careful - this will choke at 501 plots. > > > > help(pdf) > > .. > > There is an internal limit of 500 pages per PDF file, which should > > be ample. > > .. > > > > If you really want to do 1000 plots, you need a Plan B. > > > > Cheers > > > > Jason > > > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._