Plot optimization [Was: Re: [R] Plotting Speed: R vs Octave]

Ben Bolker ben at zoo.ufl.edu
Tue Dec 3 23:44:02 CET 2002


  I won't say I know exactly what's going on here, but ... can you simply 
do something like

xycomb <- paste(x,y)
dups <- duplicated(xycomb)
x <- x[!dups]
y <- y[!dups]
plot(x,y)

If you mess with rounding x and y before you paste them, this could also 
give you a way of thinning your plot [although the results would be 
slightly random depending on which points came first]

  It seems to make more sense to put a tiny bit of effort into thinning 
the points at your end rather than building code into R's postscript 
driver to deal with this case.


On Tue, 3 Dec 2002, Matej Cepl wrote:

> Deepayan Sarkar wrote:
> > Also, wireframe code is currently far from optimized (it makes
> > a separate R level function call to draw each quadrilateral).
> > It would be more interesting to know why (and how much) persp
> > is slower.
> 
> On somehow different note. I have asked couple of days ago about
> possibility of optimalization of plotting functions (pairs
> function created for me 0.5MB pictures). Answer was more or less
> unsatisfactory. I do not want bother you about that again, but
> I have took a look at the EPS file itself and this is what
> I found these interesting lines
> 
> 	% these are definitions
> 	/c { newpath 0 360 arc } def
> 	/p1  { stroke } def
> 
> 	% and than there is a many thousand
> 	% lines like these (something around 80k to be exact)
> 	
> 	330.89 387.93 1.63 c p1
> 	330.89 377.14 1.63 c p1
> 	330.89 377.14 1.63 c p1
> 	330.89 387.93 1.63 c p1
> 	330.89 387.93 1.63 c p1
> 
> If I understand well these lines use procedure /c for drawing
> a circle in particular positions, many times overplotting
> previously already drawn points (statistically speaking, not
> points in terms of pixels).
> 
> PDF file created with these pictures prettly certainly kicked
> down any laser printer I was pushing it through. Do you think,
> that it would not be possible somehow to optimize PostScript
> coming from R (at least to avoid overplotting by calling exactly
> the same procedure at exactly same points)?
> 
> The example file is attached.
> 
> Matej
> 
> 

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704




More information about the R-help mailing list