[R] slowness of plot(x, type='l')

From: <apjaworski_at_mmm.com>
Date: Sat 07 May 2005 - 06:19:01 EST

A couple of days ago a few messages indicated that something changed in the basic plot routine that made plot(*, type='l') slow for large data sets. Some people even reported crashes for very large data sets. As far as I remember, this was not reported as a formal bug.

I am still not sure if this is a bug, so I report my findings here. First of all, I think I see a slowdown of the plot function, although I do not have older versions of R installed, so I cannot do side-by-side comparisons. Secondly, I noticed that the behavior of plot(*, type='l') differs. Before R-2.1, the plotted lines would appear on the plot gradually. Now, after the wait, the whole plot appears at once.

Here are my timing results. I am on Windows2000, IBM Intellistation with Xenon 2.8MHz with 1Gb of memory. I checked May-06 versions of R-patched and R-devel built from sources. I ran the following simple test:

x <- rnorm(n)
date(); plot(x, type='l'); date()

Here are the timings:

      n     seconds
      5000  1
      6000  2
      7000  4
      8000  6
      9000  9
      10000 13
      12000 22
      14000 36
      20000 91

It looks like only type='l' and type='o' exhibit this behavior. All other types produce plots in approximately 1 second. Also, the (long) wait and plot at once behavior happens with the two types mentioned. All others (except 'n' of course) produce gradually appearing plots.

Hope this helps,


Andy Jaworski
Process Laboratory
3M Corporate Research Laboratory

E-mail: apjaworski@mmm.com
Tel: (651) 733-6092

Fax: (651) 736-3122

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat May 07 07:10:52 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST