From: Christopher Barker <Chris.B<arker@no...>  20090516 00:44:06

Christopher Barker wrote: > Hi all, > > I've been messing with quiver a bit, and have some confusions: one more issue with quiver  autoscaling fails if there is a NaN in the data: x = (1,2) y = (1,2) u = (2,2) v = (2,2) fig = plt.figure(1) fig.clear() ax = fig.add_subplot(2,2,3) # fails for a nan data point if autoscaling u = (2, np.nan) props = {'units' : "dots", 'scale' : .1, 'width' : 2, 'headwidth': 2, 'headlength': 3, 'headaxislength': 4, } ax.quiver( x, y, u, v, **props ) Chris  Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 5266959 voice 7600 Sand Point Way NE (206) 5266329 fax Seattle, WA 98115 (206) 5266317 main reception Chris.Barker@... 
From: Christopher Barker <Chris.B<arker@no...>  20090515 23:52:41
Attachments:
quiver_test.py

Hi all, I've been messing with quiver a bit, and have some confusions: according to the docs: """ units: [‘width’  ‘height’  ‘dots’  ‘inches’  ‘x’  ‘y’ ] arrow units; the arrow dimensions except for length are in multiples of this unit. """ and yes, when I change units from 'dots' for 'inched', the length of the arrows do indeed change. """ angles: [‘uv’  ‘xy’  array] ... Alternatively, arbitrary angles may be specified as an array of values in degrees, CCW from the xaxis. """ This crashes for me with: Traceback (most recent call last): File "quiver_test.py", line 72, in <module> plt.draw() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/pyplot.py", line 341, in draw get_current_fig_manager().canvas.draw() File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/backends/backend_tkagg.py", line 215, in draw FigureCanvasAgg.draw(self) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/backends/backend_agg.py", line 279, in draw self.figure.draw(self.renderer) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/figure.py", line 772, in draw for a in self.axes: a.draw(renderer) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/axes.py", line 1601, in draw a.draw(renderer) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", line 425, in draw verts = self._make_verts(self.U, self.V) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", line 484, in _make_verts theta = ma.asarray(self.angles*np.pi/180.0).filled(0) TypeError: can't multiply sequence by nonint of type 'float' I've enclosed a small test script... Thanks, Chris  Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 5266959 voice 7600 Sand Point Way NE (206) 5266329 fax Seattle, WA 98115 (206) 5266317 main reception Chris.Barker@... 
From: Christopher Barker <Chris.B<arker@no...>  20090516 00:44:06

Christopher Barker wrote: > Hi all, > > I've been messing with quiver a bit, and have some confusions: one more issue with quiver  autoscaling fails if there is a NaN in the data: x = (1,2) y = (1,2) u = (2,2) v = (2,2) fig = plt.figure(1) fig.clear() ax = fig.add_subplot(2,2,3) # fails for a nan data point if autoscaling u = (2, np.nan) props = {'units' : "dots", 'scale' : .1, 'width' : 2, 'headwidth': 2, 'headlength': 3, 'headaxislength': 4, } ax.quiver( x, y, u, v, **props ) Chris  Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 5266959 voice 7600 Sand Point Way NE (206) 5266329 fax Seattle, WA 98115 (206) 5266317 main reception Chris.Barker@... 
From: Eric Firing <efiring@ha...>  20090516 02:42:24

Christopher Barker wrote: > Christopher Barker wrote: >> Hi all, >> >> I've been messing with quiver a bit, and have some confusions: > > one more issue with quiver  autoscaling fails if there is a NaN in the > data: > I just committed a change to ensure that nans and infs are treated as masked points. If you still see the problem (and I suspect you will), then it is inherent in the autoscaling. Eric > > > x = (1,2) > y = (1,2) > u = (2,2) > v = (2,2) > > > fig = plt.figure(1) > fig.clear() > > ax = fig.add_subplot(2,2,3) > > # fails for a nan data point if autoscaling > u = (2, np.nan) > props = {'units' : "dots", > 'scale' : .1, > 'width' : 2, > 'headwidth': 2, > 'headlength': 3, > 'headaxislength': 4, > } > > ax.quiver( x, y, u, v, **props ) > > > > > Chris > > 
From: Eric Firing <efiring@ha...>  20090516 01:05:20

Christopher Barker wrote: > Hi all, > > I've been messing with quiver a bit, and have some confusions: No, you hit a bug. Thanks for the report and test script. It is fixed in r7103. If you are not running from svn, a workaround may be to specify the angles as an ndarray or masked array with the shape set to (N,1) where N is the number of arrows. I haven't tested it, but based on the changes I made, I think this will work with the version you have. Eric > > according to the docs: > > """ > units: [‘width’  ‘height’  ‘dots’  ‘inches’  ‘x’  ‘y’ ] > > arrow units; the arrow dimensions except for length are in > multiples of this unit. > """ > > and yes, when I change units from 'dots' for 'inched', the length of the > arrows do indeed change. > > > """ > angles: [‘uv’  ‘xy’  array] > ... Alternatively, arbitrary angles may be specified as an array of > values in degrees, CCW from the xaxis. > """ > > This crashes for me with: > > Traceback (most recent call last): > File "quiver_test.py", line 72, in <module> > plt.draw() > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/pyplot.py", > line 341, in draw > get_current_fig_manager().canvas.draw() > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/backends/backend_tkagg.py", > line 215, in draw > FigureCanvasAgg.draw(self) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/backends/backend_agg.py", > line 279, in draw > self.figure.draw(self.renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/figure.py", > line 772, in draw > for a in self.axes: a.draw(renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/axes.py", > line 1601, in draw > a.draw(renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", > line 425, in draw > verts = self._make_verts(self.U, self.V) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/sitepackages/matplotlib/quiver.py", > line 484, in _make_verts > theta = ma.asarray(self.angles*np.pi/180.0).filled(0) > TypeError: can't multiply sequence by nonint of type 'float' > > I've enclosed a small test script... > > Thanks, > > Chris > > > > >  > >  > Crystal Reports  New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royaltyfree distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > > >  > > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers 
From: Christopher Barker <Chris.B<arker@no...>  20090518 19:12:35

Eric Firing wrote: > No, you hit a bug. Thanks for the report and test script. It is fixed > in r7103. > > If you are not running from svn, a workaround may be to specify the > angles as an ndarray or masked array with the shape set to (N,1) where N > is the number of arrows. Yes, that seems to work. Thanks! Chris  Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 5266959 voice 7600 Sand Point Way NE (206) 5266329 fax Seattle, WA 98115 (206) 5266317 main reception Chris.Barker@... 
From: Christopher Barker <Chris.B<arker@no...>  20090519 19:38:37

Christopher Barker wrote: >> If you are not running from svn, a workaround may be to specify the >> angles as an ndarray or masked array with the shape set to (N,1) where N >> is the number of arrows. > > Yes, that seems to work. Thanks! However, I'm a bit confused now  if I specify the angles explicitly, how do I specify the lengths of the arrows? The docs aren't clear on this point: *angles*: ['uv'  'xy'  array] With the default 'uv', the arrow aspect ratio is 1, so that if *U*==*V* the angle of the arrow on the plot is 45 degrees CCW from the *x*axis. With 'xy', the arrow points from (x,y) to (x+u, y+v). Alternatively, arbitrary angles may be specified as an array of values in degrees, CCW from the *x*axis. does it use sqrt(x^2+y^2) as the length? Also: *units*: ['width'  'height'  'dots'  'inches'  'x'  'y' ] arrow units; the arrow dimensions *except for length* are in multiples of this unit. * 'x' or 'y': *X* or *Y* data units The arrows scale differently depending on the units. For 'x' or 'y', the arrows get larger as one zooms in; which makes it sound like when you set "units" to 'x' or 'y' that the length does get set to those units... What I'd like to be able to do is set the angles with "angles" and set the length in y units, but i can't figure out how to do that. Thanks, Chris  Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 5266959 voice 7600 Sand Point Way NE (206) 5266329 fax Seattle, WA 98115 (206) 5266317 main reception Chris.Barker@... 
From: Eric Firing <efiring@ha...>  20090519 21:22:28

Christopher Barker wrote: > Christopher Barker wrote: >>> If you are not running from svn, a workaround may be to specify the >>> angles as an ndarray or masked array with the shape set to (N,1) where N >>> is the number of arrows. >> Yes, that seems to work. Thanks! > > However, I'm a bit confused now  if I specify the angles explicitly, > how do I specify the lengths of the arrows? The docs aren't clear on > this point: > > *angles*: ['uv'  'xy'  array] > With the default 'uv', the arrow aspect ratio is 1, so that > if *U*==*V* the angle of the arrow on the plot is 45 degrees > CCW from the *x*axis. > With 'xy', the arrow points from (x,y) to (x+u, y+v). > Alternatively, arbitrary angles may be specified as an array > of values in degrees, CCW from the *x*axis. > > does it use sqrt(x^2+y^2) as the length? no, it is always sqrt(u^2+v^2), which then gets scaled according to the "units" setting together with the "scale" setting. > > Also: > > *units*: ['width'  'height'  'dots'  'inches'  'x'  'y' ] > arrow units; the arrow dimensions *except for length* are in > multiples of this unit. > > * 'x' or 'y': *X* or *Y* data units > > The arrows scale differently depending on the units. For > 'x' or 'y', the arrows get larger as one zooms in; > > which makes it sound like when you set "units" to 'x' or 'y' that the > length does get set to those units... Correct. > > What I'd like to be able to do is set the angles with "angles" and set > the length in y units, but i can't figure out how to do that. quiver(times, np.zeros((len(times),)), lengths, np.zeros(len(lengths)), angles=angles, units='y', scale=scale) Something like that should do it. I am assuming you are plotting time series. Of course, lengths and times must be the same length (where I am assuming they are 1D). I'm also assuming your data are coming as lengths and angles, not as components. Eric > > Thanks, > Chris > > > 