Ray Speth wrote:
> I believe I have found a simple change that improves the rendering speed 
> of quiver plots, which can be quite slow for large vector fields. Based 
> on some profiling, the problem appears to stem from the use of numpy's 
> MaskedArrays in PolyCollection.set_verts. If I add the following line to 
> the top of the PolyCollection.set_verts function in collections.py:
> 
>       verts = np.asarray(verts)
> 
> I find that quiver plots are drawn about 3 times as quickly, going from 
> 2.6 seconds for a 125x125 field to 0.65 seconds. This does not seem to 
> break the use of MaskedArrays as inputs, and masked regions are still 
> hidden in the final plot. I do not know if this has any adverse effects 
> in other classes that inherit from PolyCollection.

I made a change in PolyCollection.set_verts that has the effect of your 
suggestion but without affecting masked argument inputs in general.  I 
also made a bunch of other changes in quiver.py to speed things up with 
or without masked inputs, but their net effect is minimal in practice; 
your suggestion was the key.  I get a factor of 2, not 3; I think this 
must be a difference in our machines, though.  In any case, I'm glad you 
found the time sink.

Eric

> 
> Using:
> python 2.6.2 on Windows XP
> numpy 1.3.0
> matplotlib 0.98.5.3, Qt4Agg backend
> 
> I do not know why iterating over MaskedArrays is so slow, but perhaps 
> this information can be used to speed up some other functions as well.
> 
> Ray Speth
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to