Interesting plot behavior

David Bateman dbateman at dbateman.org
Wed Apr 15 16:02:46 CDT 2009


Robert T. Short wrote:
> I use scatter plots regularly in my work, usually with thousands or 
> tens of thousands of points.
>
> This little script is a trivial example:
>
>
> N = 2^14;
> stddev = 0.1;
>
> q = 2*((floor(4*rand(N,1))-1.5) + i*(floor(4*rand(N,1))-1.5));
> n = stddev*(randn(N,1) + i*randn(N,1));
> m =  q + n;
> %scatter(real(m),imag(m), 1, 'g');
> plot(real(m),imag(m), ".g;;");
> axis("square");
>
> Using scatter and tic/toc, it takes 120 seconds to display 2^14 points 
> but using plot it is so quick I can't really measure it.
>
> This table gives the times (time until the plot is actually displayed) 
> as a function of "N"
>
> 2^10  3 seconds
> 2^11  6 seconds
> 2^12  14 seconds
> 2^13  41 seconds
> 2^14  120 seconds
>
>
>
> This was done with octave 3.0, but I get similar behavior using the 
> tip (cloned and built yesterday)
>
> Bob
> -- 
> Robert T. Short
> PhaseLocked Systems
>
>
>
Yeah blame Mathworks.. In their wisdom they decided that each point in a 
scatter plot is a separate patch object with a separate handle.. 
Unfortunately Octave with the gnuplot backend then plots each of those 
patch objects with a separate plot command, thus the speed issues. I 
don't think its that easy to speed this up for the gnuplot backend as we 
have to assume that each patch object can have a different color (though 
in your case it doesn't) and so I can't see an easy way to plot all of 
the patches together.. Perhaps a different graphics backend will be 
faster for this case.

D.

-- 
David Bateman                                dbateman at dbateman.org
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)



More information about the Octave-maintainers mailing list