[R] Pdf file size for very scatter plots
Dear all, I am plotting a scatter plot for a large sample (1e+05 ordered pairs). This produces a large (~5MB) file in a pdf or postscript terminal, and I am wondering whether there are methods for reducing the size of the resulting file so that it is easier to include it in a document. I'd rather stick with pdf or ps as I am using latex. thanks, Nazareno __ 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] Pdf file size for very scatter plots
Have you tried using pch='.'? Also you might consider using 'hexbin' for creating the scatter plot. On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade <[EMAIL PROTECTED]> wrote: > Dear all, > > I am plotting a scatter plot for a large sample (1e+05 ordered pairs). > This produces a large (~5MB) file in a pdf or postscript terminal, and > I am wondering whether there are methods for reducing the size of the > resulting file so that it is easier to include it in a document. I'd > rather stick with pdf or ps as I am using latex. > > thanks, > Nazareno > > __ > 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] Pdf file size for very scatter plots
Jim, Thanks for the answer. Using pch="." reduces the file to ~3MB... Still large. I'll look into hexbins, but if I understand it right, it would 'round' points which are nearby into a same hexagon, right? Couldn't that result in an inaccurate view of a scatter plot? Here's the code I'm using: pdf(); plot(rnorm(1e5), rnorm(1e5), pch = "."); dev.off() thanks again, Nazareno On Fri, Aug 15, 2008 at 12:27 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Have you tried using pch='.'? > > Also you might consider using 'hexbin' for creating the scatter plot. > > On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade > <[EMAIL PROTECTED]> wrote: >> Dear all, >> >> I am plotting a scatter plot for a large sample (1e+05 ordered pairs). >> This produces a large (~5MB) file in a pdf or postscript terminal, and >> I am wondering whether there are methods for reducing the size of the >> resulting file so that it is easier to include it in a document. I'd >> rather stick with pdf or ps as I am using latex. >> >> thanks, >> Nazareno >> >> __ >> 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] Pdf file size for very scatter plots
Nazareno Andrade lsd.ufcg.edu.br> writes: > > Jim, > > Thanks for the answer. Using pch="." reduces the file to ~3MB... Still large. > > I'll look into hexbins, but if I understand it right, it would 'round' > points which are nearby into a same hexagon, right? Couldn't that > result in an inaccurate view of a scatter plot? > > Here's the code I'm using: > > pdf(); plot(rnorm(1e5), rnorm(1e5), pch = "."); dev.off() > > thanks again, > Nazareno > > On Fri, Aug 15, 2008 at 12:27 PM, jim holtman gmail.com> wrote: > > Have you tried using pch='.'? > > > > Also you might consider using 'hexbin' for creating the scatter plot. > > > > On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade > > lsd.ufcg.edu.br> wrote: > >> Dear all, > >> > >> I am plotting a scatter plot for a large sample (1e+05 ordered pairs). > >> This produces a large (~5MB) file in a pdf or postscript terminal, and > >> I am wondering whether there are methods for reducing the size of the > >> resulting file so that it is easier to include it in a document. I'd > >> rather stick with pdf or ps as I am using latex. > >> > >> thanks, > >> Nazareno > >> You can embed png in a LaTeX file if you want: google "latex png". The problem is that lots of these points overlap, and they're all going into the PDF file whether or not they're visible in the plot or not. I just did png(file="a.png",height=2000,width=2000) ... dev.off() which created a 100K file with resolution much higher than that of my screen, on which every distinct point seems to be visible. I suppose you could try to thin the data set by figuring out which points are exactly on top of each other at a given resolution (by rounding, pasting columns together and looking for duplicates, or perhaps by using hexbin at a ridiculously high resolution), but the PNG solution seems much easier. good luck, Ben Bolker __ 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] Pdf file size for very scatter plots
Jim, Thanks for the answer. Using pch="." reduces the file to ~3MB... Still large. I'll look into hexbins, but if I understand it right, it would 'round' points which are nearby into a same hexagon, right? Couldn't that result in an inaccurate view of a scatter plot? Here's the code I'm using: pdf(); plot(rnorm(1e5), rnorm(1e5), pch = "."); dev.off() thanks again, Nazareno On Fri, Aug 15, 2008 at 12:27 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Have you tried using pch='.'? > > Also you might consider using 'hexbin' for creating the scatter plot. > > On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade > <[EMAIL PROTECTED]> wrote: >> Dear all, >> >> I am plotting a scatter plot for a large sample (1e+05 ordered pairs). >> This produces a large (~5MB) file in a pdf or postscript terminal, and >> I am wondering whether there are methods for reducing the size of the >> resulting file so that it is easier to include it in a document. I'd >> rather stick with pdf or ps as I am using latex. >> >> thanks, >> Nazareno >> >> __ >> 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] Pdf file size for very scatter plots
I thought running it through latex will compress the pdf - but this post nicely summarizes some options: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html I personally prefer the pdftk approach* over the ghostscript option** as the latter seems to give me a number of problems on Windows XP. *if you install pdftk (and put it in your search path), after you create filename.pdf with pdf(), do pdftk filename.pdf cat output newfilename.pdf compress or pdftk filename.pdf cat output newfilename.pdf compress dont_ask **if you have ghostview installed (and in your search path), bitmap("filename.pdf",type="pdfwrite") plot(...) dev.off() - Original Message From: Nazareno Andrade <[EMAIL PROTECTED]> To: r-help Sent: Friday, August 15, 2008 12:46:52 PM Subject: Re: [R] Pdf file size for very scatter plots Jim, Thanks for the answer. Using pch="." reduces the file to ~3MB... Still large. I'll look into hexbins, but if I understand it right, it would 'round' points which are nearby into a same hexagon, right? Couldn't that result in an inaccurate view of a scatter plot? Here's the code I'm using: pdf(); plot(rnorm(1e5), rnorm(1e5), pch = "."); dev.off() thanks again, Nazareno On Fri, Aug 15, 2008 at 12:27 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Have you tried using pch='.'? > > Also you might consider using 'hexbin' for creating the scatter plot. > > On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade > <[EMAIL PROTECTED]> wrote: >> Dear all, >> >> I am plotting a scatter plot for a large sample (1e+05 ordered pairs). >> This produces a large (~5MB) file in a pdf or postscript terminal, and >> I am wondering whether there are methods for reducing the size of the >> resulting file so that it is easier to include it in a document. I'd >> rather stick with pdf or ps as I am using latex. >> >> thanks, >> Nazareno >> >> __ >> 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. __ 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] Pdf file size for very scatter plots
The best way is to try it and see if you like it. I have used it on plots with 150,000 point and it provided a good picture of what was going on. Sent from my iPhone On Aug 15, 2008, at 13:52, Stephen Tucker <[EMAIL PROTECTED]> wrote: I thought running it through latex will compress the pdf - but this post nicely summarizes some options: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html I personally prefer the pdftk approach* over the ghostscript option** as the latter seems to give me a number of problems on Windows XP. *if you install pdftk (and put it in your search path), after you create filename.pdf with pdf(), do pdftk filename.pdf cat output newfilename.pdf compress or pdftk filename.pdf cat output newfilename.pdf compress dont_ask **if you have ghostview installed (and in your search path), bitmap("filename.pdf",type="pdfwrite") plot(...) dev.off() - Original Message From: Nazareno Andrade <[EMAIL PROTECTED]> To: r-help Sent: Friday, August 15, 2008 12:46:52 PM Subject: Re: [R] Pdf file size for very scatter plots Jim, Thanks for the answer. Using pch="." reduces the file to ~3MB... Still large. I'll look into hexbins, but if I understand it right, it would 'round' points which are nearby into a same hexagon, right? Couldn't that result in an inaccurate view of a scatter plot? Here's the code I'm using: pdf(); plot(rnorm(1e5), rnorm(1e5), pch = "."); dev.off() thanks again, Nazareno On Fri, Aug 15, 2008 at 12:27 PM, jim holtman <[EMAIL PROTECTED]> wrote: Have you tried using pch='.'? Also you might consider using 'hexbin' for creating the scatter plot. On Fri, Aug 15, 2008 at 12:24 PM, Nazareno Andrade <[EMAIL PROTECTED]> wrote: Dear all, I am plotting a scatter plot for a large sample (1e+05 ordered pairs). This produces a large (~5MB) file in a pdf or postscript terminal, and I am wondering whether there are methods for reducing the size of the resulting file so that it is easier to include it in a document. I'd rather stick with pdf or ps as I am using latex. thanks, Nazareno __ 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. __ 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-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.