Hi, I'm just wondering how I can do to make a huge postscript plot be manageable. My question is that I have to draw around 60,000 points which makes it painfully slow to print or view in gv or put it into latex document, though it is very fast to produce the postscript file. A simple example is in the attachment. Well, I found that if I use png or jpeg. It is much faster to view the figure. The only problem is that the x label, y label are using bitmapped font so it doesn't look as beautiful as postscript. Sometimes it is just hard to read the legend which consists of information how to interpret the figure. My question is that if there are some options or packages such that when we are plotting many points or lines, the plot uses the bitmapped (raster) format, but for the characters, like the x label, y label, and the title, it uses the native font. pdf seems use the above approach and is very fast, but I have to use pdf2ps to convert the pdf file to ps file. It is still slow. If you know other good converter of pdf file to ps file, i will also very appreciate it. Thanks, Yongchao x<-1:2000 y<-matrix(rnorm(2000*12),2000,12) for(i in 1:12){ y[,i]<-sort(y[,i]+i*0.5) } postscript("try.ps") matplot(x,y,type="l",lwd=5) dev.off()
Yongchao Ge <gyc at stat.berkeley.edu> wrote:> I'm just wondering how I can do to make a huge postscript plot be > manageable. My question is that I have to draw around 60,000 points which > makes it painfully slow to print or view in gv or put it into latex > document, though it is very fast to produce the postscript file. > > A simple example is in the attachment. > > > x<-1:2000 > y<-matrix(rnorm(2000*12),2000,12) > for(i in 1:12){ > y[,i]<-sort(y[,i]+i*0.5) > } > postscript("try.ps") > matplot(x,y,type="l",lwd=5) > dev.off()How about sampling a subset of the data: sub=sort(sample(x,200, replace=F)) postscript("try.ps") matplot(x[sub],y[sub,],type="l",lwd=5) dev.off() -- Philippe
How about pdf(), jpeg() or png() ? -----Original Message----- From: Philippe Glaziou [mailto:glaziou at pasteur-kh.org] Sent: Saturday, July 05, 2003 9:47 AM To: r-help at stat.math.ethz.ch Subject: Re: [R] the huge postscript plot Yongchao Ge <gyc at stat.berkeley.edu> wrote:> I'm just wondering how I can do to make a huge postscript plot be > manageable. My question is that I have to draw around 60,000 points > which makes it painfully slow to print or view in gv or put it into > latex document, though it is very fast to produce the postscript file. > > A simple example is in the attachment. > > > x<-1:2000 > y<-matrix(rnorm(2000*12),2000,12) > for(i in 1:12){ > y[,i]<-sort(y[,i]+i*0.5) > } > postscript("try.ps") > matplot(x,y,type="l",lwd=5) > dev.off()How about sampling a subset of the data: sub=sort(sample(x,200, replace=F)) postscript("try.ps") matplot(x[sub],y[sub,],type="l",lwd=5) dev.off() -- Philippe ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
On Fri, 4 Jul 2003, Yongchao Ge wrote:> Hi, > > I'm just wondering how I can do to make a huge postscript plot be > manageable. My question is that I have to draw around 60,000 points which > makes it painfully slow to print or view in gv or put it into latex > document, though it is very fast to produce the postscript file. > > A simple example is in the attachment. > > Well, I found that if I use png or jpeg. It is much faster to view > the figure. The only problem is that the x label, y label are using > bitmapped font so it doesn't look as beautiful as postscript. Sometimes it > is just hard to read the legend which consists of information how to > interpret the figure.Only if scaling is involved: try setting the resolution so you view it at 1:1.> My question is that if there are some options or packages such that when > we are plotting many points or lines, the plot uses the bitmapped (raster) > format, but for the characters, like the x label, y label, and the title, > it uses the native font. > > pdf seems use the above approach and is very fast, but I have to useIt doesn't use that approach: PDF is primarily a vector format, and that's what R's pdf() driver produces.> pdf2ps to convert the pdf file to ps file. It is still slow. If you know > other good converter of pdf file to ps file, i will also very appreciate > it.Which points up that the problem is in your .ps viewer, nowhere else. That's not surprising; postscript is a *print* description language and primarily intended for high-quality printing. For a long time postscript printers contained more powerful processors than workstations (let alone PCs). Your example is not `painfully slow' on my printer (nor to view with ghostscript, to give due credit to the engine behind gv), but it is also not an interesting plot, nor is it `huge'. -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi Matt, Thanks for the help. I'm just wondering if some package or some options in par or ps.options exists so that I can just use it directly. As we know, we can not just randomly sample 1000 of them as we may miss some important extreme points (outliers). We need to define a small distance d, when a clouds of points are within the distance of d, then we can randomly sample a few points from each clouds so we don't lose any visual information. What it really needs is a fast algorithm to group 60,000 points into 1000+ of clusters. Each cluster's radius must be less than d. We can surely work this way. Again, let's go back to my original question, I'd like to find a fast way to plot the points into a bitmapped (raster) format, say 600x800. This is just an informal way of the sampling strategy defined in the first graph and the radius d is defined by the dimension size of the plot (600x800). The larger dimension size, the smaller the radius d is. If such package or options exists in R, please let me know as it can save me enormous of time for the programming. Yongchao On Fri, 4 Jul 2003, Wiener, Matthew wrote:> One possibility is to sample your 60,000 points, since you probably can't > see them all distinctly anyway. You could sample, say, 10000 of them. > > Hope this helps, > > Matt Wiener > > -----Original Message----- > From: Yongchao Ge [mailto:gyc at stat.berkeley.edu] > Sent: Friday, July 04, 2003 7:06 PM > To: r-help at stat.math.ethz.ch > Subject: [R] the huge postscript plot > > > Hi, > > I'm just wondering how I can do to make a huge postscript plot be > manageable. My question is that I have to draw around 60,000 points which > makes it painfully slow to print or view in gv or put it into latex > document, though it is very fast to produce the postscript file. > > A simple example is in the attachment. > > Well, I found that if I use png or jpeg. It is much faster to view > the figure. The only problem is that the x label, y label are using > bitmapped font so it doesn't look as beautiful as postscript. Sometimes it > is just hard to read the legend which consists of information how to > interpret the figure. > > My question is that if there are some options or packages such that when > we are plotting many points or lines, the plot uses the bitmapped (raster) > format, but for the characters, like the x label, y label, and the title, > it uses the native font. > > pdf seems use the above approach and is very fast, but I have to use > pdf2ps to convert the pdf file to ps file. It is still slow. If you know > other good converter of pdf file to ps file, i will also very appreciate > it. > > > Thanks, > > Yongchao > > x<-1:2000 > y<-matrix(rnorm(2000*12),2000,12) > for(i in 1:12){ > y[,i]<-sort(y[,i]+i*0.5) > } > postscript("try.ps") > matplot(x,y,type="l",lwd=5) > dev.off() > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > ------------------------------------------------------------------------------ > Notice: This e-mail message, together with any attachments, contains > information of Merck & Co., Inc. (Whitehouse Station, New Jersey, > USA) that may be confidential, proprietary copyrighted and/or legally > privileged, and is intended solely for the use of the individual or entity > named on this message. If you are not the intended recipient, and > have received this message in error, please immediately return this by > e-mail and then delete it. > ------------------------------------------------------------------------------ >
> Another alternative is to insert pdf graphs into latex. The way you do this > is to use pdflatex with the graphicx package. In the preamble of your latex > document, put > > \usepackage[pdftex]{graphicx} instead of \usepackage[dvips]{graphicx} > > somewhere. When you run the document, use pdflatex file.tex instead of > latex. Otherwise, it's essentially the same process. The only headache is > that pdflatex won't let you overwrite an existing pdf output file, but > there are clearly many ways to handle that little annoyance.Hi Dennis, Sure, this works out but I need to produce ps and pdf documents so I have to use dvips and ps2pdf, not pdflatex. I also need to convert all my ps file to pdf file by epstopdf, which is OK, but may not be perfect. I still like to have a solution that can work it on the level of producing ps file from R environment.
The sunflowerplot function in base, or the hexbin package in Bioconductor, could possibly be useful for this. Andy> -----Original Message----- > From: Yongchao Ge [mailto:gyc at stat.berkeley.edu] > Sent: Saturday, July 05, 2003 3:06 AM > To: r-help at stat.math.ethz.ch > Subject: RE: [R] the huge postscript plot > > > Hi Matt, > > Thanks for the help. I'm just wondering if some package or > some options in par or ps.options exists so that I can just > use it directly. As we know, we can not just randomly sample > 1000 of them as we may miss some important extreme points > (outliers). We need to define a small distance d, when a > clouds of points are within the distance of d, then we can > randomly sample a few points from each clouds so we don't > lose any visual information. What it really needs is a fast > algorithm to group 60,000 points into 1000+ of clusters. Each > cluster's radius must be less than d. > > We can surely work this way. Again, let's go back to my > original question, I'd like to find a fast way to plot the > points into a bitmapped (raster) format, say 600x800. This is > just an informal way of the sampling strategy defined in the > first graph and the radius d is defined by the dimension size > of the plot (600x800). The larger dimension size, the > smaller the radius d is. > > If such package or options exists in R, please let me know as > it can save me enormous of time for the programming. > > Yongchao > > > On Fri, 4 Jul 2003, Wiener, Matthew wrote: > > > One possibility is to sample your 60,000 points, since you probably > > can't see them all distinctly anyway. You could sample, > say, 10000 of > > them. > > > > Hope this helps, > > > > Matt Wiener > > > > -----Original Message----- > > From: Yongchao Ge [mailto:gyc at stat.berkeley.edu] > > Sent: Friday, July 04, 2003 7:06 PM > > To: r-help at stat.math.ethz.ch > > Subject: [R] the huge postscript plot > > > > > > Hi, > > > > I'm just wondering how I can do to make a huge postscript plot be > > manageable. My question is that I have to draw around 60,000 points > > which makes it painfully slow to print or view in gv or put it into > > latex document, though it is very fast to produce the > postscript file. > > > > A simple example is in the attachment. > > > > Well, I found that if I use png or jpeg. It is much faster > to view the > > figure. The only problem is that the x label, y label are using > > bitmapped font so it doesn't look as beautiful as postscript. > > Sometimes it is just hard to read the legend which consists of > > information how to interpret the figure. > > > > My question is that if there are some options or packages such that > > when we are plotting many points or lines, the plot uses > the bitmapped > > (raster) format, but for the characters, like the x label, y label, > > and the title, it uses the native font. > > > > pdf seems use the above approach and is very fast, but I > have to use > > pdf2ps to convert the pdf file to ps file. It is still slow. If you > > know other good converter of pdf file to ps file, i will also very > > appreciate it. > > > > > > Thanks, > > > > Yongchao > > > > x<-1:2000 > > y<-matrix(rnorm(2000*12),2000,12) > > for(i in 1:12){ > > y[,i]<-sort(y[,i]+i*0.5) > > } > > postscript("try.ps") > > matplot(x,y,type="l",lwd=5) > > dev.off() > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > > ---------------------------------------------------------------------- > > -------- > > Notice: This e-mail message, together with any attachments, contains > > information of Merck & Co., Inc. (Whitehouse Station, New Jersey, > > USA) that may be confidential, proprietary copyrighted > and/or legally > > privileged, and is intended solely for the use of the > individual or entity > > named on this message. If you are not the intended recipient, and > > have received this message in error, please immediately > return this by > > e-mail and then delete it. > > > -------------------------------------------------------------- > ---------------- > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, ...{{dropped}}