Skip to content
Prev 69316 / 398530 Next

slowness of plot(x, type='l')

Plotting times depend on the graphics device.  That is nowhere mentioned 
here, which is unhelpful, and we have already seen a post saying it does 
not happen on another unmentioned device (presumably X11).

Let us assume the unmentioned device was windows(), as that is the only 
one I see any slowdown for.  (Others like win.metafile are windows() under 
the skin.)
On Fri, 6 May 2005 apjaworski at mmm.com wrote:

            
Well, _is_ there a bug in R (as distinct from in Windows graphics 
internals)?  I am almost certain there is not in R and this is a bug in 
Windows.
Oh, PLEASE, use system.time() to time things.  Had you done so you might 
have seen things like
[1]  0.03 13.11 13.21    NA    NA
[1] 0.07 0.00 0.08   NA   NA
[1] 0.07 0.93 1.00   NA   NA

so the time is not being taken by R but by Windows.

I can tell you the reason: it is the support for mitred etc line ends 
introduced in R 2.0.0 and only supported in windows() from 2.1.0.  This 
has slowed solid lines down to the sort of times taken for dashed lines 
previously.

Now, the best we can do to work around this is to follow what we did for 
dashed lines, and not attempt to be accurate for very large numbers of 
line segments.  By plotting in bunches of 1000 lines I get
[1] 0.03 0.36 0.42   NA   NA
[1] 0.22 2.89 3.11   NA   NA

We have been here before, and as I recall this slowdown happens only in 
NT-based versions of Windows which seem _de facto_ restricted to about 
1000 line elements in a path: what we were not aware of was that it 
happened for solid lines as well as dashed ones.

I've put the bunching into R-patched.

It is very regretable that this sort of thing was not tested for during 
beta-testing.