From: <js...@us...> - 2008-08-22 19:19:09
|
Revision: 6047 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6047&view=rev Author: jswhit Date: 2008-08-22 19:19:07 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix quiver so masked values are not plotted. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/quiver_demo.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/pylab_examples/quiver_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-21 15:29:12 UTC (rev 6046) +++ trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-22 19:19:07 UTC (rev 6047) @@ -9,6 +9,7 @@ ''' from pylab import * +from numpy import ma X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) ) U = cos(X) @@ -64,6 +65,20 @@ axis([-1, 7, -1, 7]) title("triangular head; scale with x view; black edges") +#6 +figure() +M = zeros(U.shape, dtype='bool') +M[U.shape[0]/3:2*U.shape[0]/3,U.shape[1]/3:2*U.shape[1]/3] = True +U = ma.masked_array(U, mask=M) +V = ma.masked_array(V, mask=M) +Q = quiver( U, V) +qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W', + fontproperties={'weight': 'bold'}) +l,r,b,t = axis() +dx, dy = r-l, t-b +axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy]) +title('Minimal arguments, no kwargs - masked values') + show() Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-21 15:29:12 UTC (rev 6046) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-22 19:19:07 UTC (rev 6047) @@ -334,6 +334,12 @@ def __init__(self, ax, *args, **kw): self.ax = ax X, Y, U, V, C = self._parse_args(*args) + if C is not None: + X, Y, U, V, C = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel(),C.ravel()) + else: + X, Y, U, V = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel()) self.X = X self.Y = Y self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |