[R] Exporting Numerous Graphs
Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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] Exporting Numerous Graphs
I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Pretty sure PNG can only cope with single 'page' images - the page can be as big as it wants but then when it comes to things like printing its gonna cause problems as I doubt many graphics packages can split it over the page? So they'll either crop it or scale it. 27 on 1 page is gonna be very small? TIFF can handle multiple pages and of course so can PDF. I don't know of an export to TIFF function. So I'd suggest exporting to PDF - and exporting to 27 different file names (1 to 27.pdf) Then using a tool like pdfshuffler (linux GUI based) or using command line ghostscript (windows or linux) gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf 1.pdf 2.pdf 3.pdf ...etc... 27.pdf (This is a linux command not a R command. The widnwos version will be very simillar I suspect) That'd give you a 27 page pdf file with each graph on a new page? Much easier to scroll through than using a scroll bar on a graphics package - you can go back to Page 5 and on to page 9 to compare quickly rather than having to manually scroll to find the right info. Plus PDF is vector based which means future importing into decent desktop publishing packages should avoid and issues with loss / scaling. I believe its also possible with psmerge using postscript and so possible EPS files. This message may contain confidential information. If yo...{{dropped:21}} __ R-help@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.
Re: [R] Exporting Numerous Graphs
Hi, It's probably easiest with the pdf (or postscript) device, pdf(all.pdf) for(ii in 1:27) plot(rnorm(10), main=paste(plot, ii)) dev.off() Bitmap-based devices can generate sequential filenames (Rplot1.png, Rplot2.png, ...) that you could combine in a single document using external tools (e.g. a pdf file with latex, or an html template that you can view in a browser, etc.). For example, create the following file template.brew, !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html lang=en head meta http-equiv=content-type content=text/html; charset=utf-8 titletitle/title link rel=stylesheet type=text/css href=style.css script type=text/javascript src=script.js/script /head body % for (ii in 1:27) { filename - paste(plot,ii, .png, sep=) png(filename) plot(rnorm(10), main=paste(plot, ii)) dev.off() % pimg src=% cat(filename) % p/ % } % /body /html and process it in R using, library(brew) brew(template.brew, template.html) HTH, baptiste 2009/9/14 Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Pretty sure PNG can only cope with single 'page' images - the page can be as big as it wants but then when it comes to things like printing its gonna cause problems as I doubt many graphics packages can split it over the page? So they'll either crop it or scale it. 27 on 1 page is gonna be very small? TIFF can handle multiple pages and of course so can PDF. I don't know of an export to TIFF function. So I'd suggest exporting to PDF - and exporting to 27 different file names (1 to 27.pdf) Then using a tool like pdfshuffler (linux GUI based) or using command line ghostscript (windows or linux) gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf 1.pdf 2.pdf 3.pdf ...etc... 27.pdf (This is a linux command not a R command. The widnwos version will be very simillar I suspect) That'd give you a 27 page pdf file with each graph on a new page? Much easier to scroll through than using a scroll bar on a graphics package - you can go back to Page 5 and on to page 9 to compare quickly rather than having to manually scroll to find the right info. Plus PDF is vector based which means future importing into decent desktop publishing packages should avoid and issues with loss / scaling. I believe its also possible with psmerge using postscript and so possible EPS files. This message may contain confidential information. If ...{{dropped:29}} __ R-help@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.
Re: [R] Exporting Numerous Graphs
You can wite them out as single files (png('file-%02d.png',...)) and then import them to Word. On Mon, Sep 14, 2009 at 1:55 AM, Chris Li chri...@austwaterenv.com.au wrote: Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@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.
Re: [R] Exporting Numerous Graphs
Try this: library(RDCOMClient) w - COMCreate('Word.Application') w[[Visible]] - TRUE w[[DisplayAlerts]] - FALSE doc - w$Documents()$Add(Template=Normal, NewTemplate=FALSE, DocumentType=0) fooPasteGraphs - function(index, ...){ win.metafile() plot(rnorm(100)) dev.off() w$Selection()$Paste() } lapply(1:27, fooPasteGraphs) doc$SaveAs(FileName = graphs.doc, FileFormat = wdFormatDocument) doc$Close() w$Quit() doc - w - NULL rm(doc, w) On Mon, Sep 14, 2009 at 2:55 AM, Chris Li chri...@austwaterenv.com.auwrote: Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@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.