Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: George Nurser <gnurser@go...>  20090119 22:32:23
Attachments:
quivtest.png

I think there may be two bugs in quiver. 1. Quiver doesn't seem to accept 1D arrays X and Y if they are different sizes  they need to be turned into 2d arrays with meshgrid for the program to work. With line 13 uncommented I get the following error message: File "quivtest.py", line 13, in <module> ax.quiver(XT,YT,uu,vv) #fails File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/axes.py", line 5533, in quiver q = mquiver.Quiver(self, *args, **kw) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", line 343, in __init__ self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/numpy/lib/shape_base.py", line 488, in hstack return _nx.concatenate(map(atleast_1d,tup),1) ValueError: array dimensions must agree except for d_0 2. Masking is not working properly with quiver, while it works fine with contour  see the attached quivtest.png quiver.py: import numpy as np import numpy.ma as ma import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt XT = np.arange(10.) YT = np.arange(20.) uu = np.zeros([20,10])+7. vv = np.zeros([20,10])+3. fig = plt.figure() ax = fig.add_subplot(121) # ax.quiver(XT,YT,uu,vv) #fails XX,YY = np.meshgrid(XT,YT) ax.quiver(XX,YY,uu,vv) #Ok ax = fig.add_subplot(122) msk = XX**2+YY**2 >50 uumsk = ma.masked_array(uu,mask=msk) vvmsk = ma.masked_array(vv,mask=msk) ax.contour(XT,YT,uumsk*XX) # works ax.quiver(XX,YY,uumsk,vvmsk) # gives strange shapes plt.show() fig.savefig('quivtest.png',dpi=100) George Nurser. 
From: Eric Firing <efiring@ha...>  20090119 23:42:53

George Nurser wrote: > I think there may be two bugs in quiver. Thanks for the report. I can reproduce both problems, and I will try to solve them. Eric > > 1. Quiver doesn't seem to accept 1D arrays X and Y if they are > different sizes  they need to be turned into 2d arrays with meshgrid > for the program to work. With line 13 uncommented I get the following > error message: > > File "quivtest.py", line 13, in <module> > ax.quiver(XT,YT,uu,vv) #fails > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/axes.py", > line 5533, in quiver > q = mquiver.Quiver(self, *args, **kw) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", > line 343, in __init__ > self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/numpy/lib/shape_base.py", > line 488, in hstack > return _nx.concatenate(map(atleast_1d,tup),1) > ValueError: array dimensions must agree except for d_0 > > 2. Masking is not working properly with quiver, while it works fine > with contour  see the attached quivtest.png > > quiver.py: > > import numpy as np > import numpy.ma as ma > import matplotlib > matplotlib.use('Agg') > import matplotlib.pyplot as plt > XT = np.arange(10.) > YT = np.arange(20.) > uu = np.zeros([20,10])+7. > vv = np.zeros([20,10])+3. > > fig = plt.figure() > ax = fig.add_subplot(121) > # ax.quiver(XT,YT,uu,vv) #fails > XX,YY = np.meshgrid(XT,YT) > ax.quiver(XX,YY,uu,vv) #Ok > > ax = fig.add_subplot(122) > msk = XX**2+YY**2 >50 > uumsk = ma.masked_array(uu,mask=msk) > vvmsk = ma.masked_array(vv,mask=msk) > ax.contour(XT,YT,uumsk*XX) # works > ax.quiver(XX,YY,uumsk,vvmsk) # gives strange shapes > plt.show() > fig.savefig('quivtest.png',dpi=100) > > George Nurser. > > >  > > >  > >  > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sfspreadtheword > > >  > > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers 
From: Eric Firing <efiring@ha...>  20090120 02:16:11

George Nurser wrote: > I think there may be two bugs in quiver. Actually just 1... > > 1. Quiver doesn't seem to accept 1D arrays X and Y if they are > different sizes  they need to be turned into 2d arrays with meshgrid > for the program to work. With line 13 uncommented I get the following > error message: This is a bug. It is fixed now in svn trunk and 98.5 maintenance branch. > > 2. Masking is not working properly with quiver, while it works fine > with contour  see the attached quivtest.png This is a numpy.ma bug that has been fixed in numpy. I don't know exactly when it was fixed, but after I tracked it down to numpy.ma, I updated my copy of numpy from svn, and the problem went away. Somehow, when a multiplication was done with broadcasting, the mask was getting handled and propagated incorrectly. I suspect this bug was present only for a moderate interval of time, because quiver with masked points worked for a long time before you ran into the bug. Eric 
From: George Nurser <gnurser@go...>  20090120 23:08:10

Downloaded latest svn numpy and matplotlib and it works perfectly now. Thanks for sorting it out so quickly. George. 2009/1/20 Eric Firing <efiring@...>: > George Nurser wrote: >> >> I think there may be two bugs in quiver. > > Actually just 1... > >> >> 1. Quiver doesn't seem to accept 1D arrays X and Y if they are >> different sizes  they need to be turned into 2d arrays with meshgrid >> for the program to work. With line 13 uncommented I get the following >> error message: > > This is a bug. It is fixed now in svn trunk and 98.5 maintenance branch. > >> >> 2. Masking is not working properly with quiver, while it works fine >> with contour  see the attached quivtest.png > > This is a numpy.ma bug that has been fixed in numpy. I don't know exactly > when it was fixed, but after I tracked it down to numpy.ma, I updated my > copy of numpy from svn, and the problem went away. Somehow, when a > multiplication was done with broadcasting, the mask was getting handled and > propagated incorrectly. I suspect this bug was present only for a moderate > interval of time, because quiver with masked points worked for a long time > before you ran into the bug. > > Eric > 
Sign up for the SourceForge newsletter:
No, thanks