octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fast scatter plots - advice sought


From: Jaroslav Hajek
Subject: fast scatter plots - advice sought
Date: Sun, 10 Jan 2010 22:18:01 +0100

hi,

I recently started some work where I'm going to use scatter plots
heavily with a few thousand points.
I found out, however, that scatter plots were unusably slow with so
many points. This has also been reported before:

http://old.nabble.com/scatter3-is-really-slow-to24312164.htm

by this changeset
http://hg.savannah.gnu.org/hgweb/octave/rev/2f435ed48143

I tried to optimize the plotting strategy to get more reasonable
times, especially in the simplest cases. The old strategy of creating
one object per point is only used for small numbers of points (<= 20).
Otherwise, the points are split into subsets with common color and
size, and these subsets are plotted using a single primitive. This
seems similar to what Matlab does.

I have several questions:
1. apparently the points were plot using the patch primitive, for
which I saw no reason. I used line instead, which seems simpler to me.
2. to reduce the number of unique sizes, the sizes are round to one
decimal place. I think this still may be unnecessarily fine, though.
The smallest visually distinguishable radius difference is likely more
than 0.1.
3. It seems that Gnuplot can accept a variable pointsize directly,
using "pointsize variable" and taking an extra column of data. So it
could be nice if we allowed "markersize" property of a line primitive
to be a vector.
I'd like to implement this extension, but I'm not sure how to do this
for the opengl backend. Any hints?

To get an idea of the speed-up, I tried before and after:

octave:1> n = 2000; x = randn (n, 1); y = randn (n, 1); figure; tic;
scatter (x, y); toc
Elapsed time is 45.0371 seconds.

(actually it took a couple more seconds for the plot to actually appear)

lt-octave:1> n = 2000; x = randn (n, 1); y = randn (n, 1); figure;
tic; scatter (x, y); toc
Elapsed time is 0.0719829 seconds.

version with variable pointsize:

octave:1> n = 2000; x = randn (n, 1); y = randn (n, 1); figure; tic;
scatter (x, y, hypot (x, y), []); toc
Elapsed time is 44.9677 seconds.

lt-octave:1> n = 2000; x = randn (n, 1); y = randn (n, 1); figure;
tic; scatter (x, y, hypot (x, y), []); toc
Elapsed time is 0.145086 seconds.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]