From: <jasonsage@cr...>  20090930 01:28:39

A couple of us are trying to figure out how to scale arrows in a quiver plot so that we can exactly specify what the output arrows look like. For example, we'd like to scale the vectors to half of their size, and have it look like that on the quiver plot. So I tried even just getting a quiver plot to plot an arrow exactly as I passed it, without it scaling anything. My attempt is this: import matplotlib.pylab as plt fig=plt.figure(figsize=[6,6]) q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy') ax=plt.axis([0,1.5,0,1.5]) plt.grid(True) plt.savefig('test.png') I'm trying to get the arrow to go from (0,0) to (1,1). However, with units='x', it's just short, and with units='y', it's just a bit too long. Furthermore, if I don't make the aspect ratio equal to one, I get wild results since the xaxis and yaxis are different units then. It would be really nice if there was a way to say units='data' (for data coordinates), and then if scale=1, the arrows would be drawn with the heads and tails at exactly the passed points. If scale=2, then each arrow would be drawn exactly half of its length. I realize that units='data' might mess up the other measurements of an arrow, though, so maybe another parameter is called for, like a scale_units, that defaults to units. What do people think? Thanks, Jason 
From: Eric Firing <efiring@ha...>  20090930 02:33:30

jasonsage@... wrote: > A couple of us are trying to figure out how to scale arrows in a quiver > plot so that we can exactly specify what the output arrows look like. > For example, we'd like to scale the vectors to half of their size, and > have it look like that on the quiver plot. > > So I tried even just getting a quiver plot to plot an arrow exactly as I > passed it, without it scaling anything. My attempt is this: > > import matplotlib.pylab as plt > fig=plt.figure(figsize=[6,6]) > q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy') > ax=plt.axis([0,1.5,0,1.5]) > plt.grid(True) > plt.savefig('test.png') > > I'm trying to get the arrow to go from (0,0) to (1,1). However, with > units='x', it's just short, and with units='y', it's just a bit too > long. Furthermore, if I don't make the aspect ratio equal to one, I get > wild results since the xaxis and yaxis are different units then. It > would be really nice if there was a way to say units='data' (for data > coordinates), and then if scale=1, the arrows would be drawn with the > heads and tails at exactly the passed points. If scale=2, then each > arrow would be drawn exactly half of its length. I realize that > units='data' might mess up the other measurements of an arrow, though, > so maybe another parameter is called for, like a scale_units, that > defaults to units. This sounds like a good idea. The present situation does the originally intended autoscaling of arrows reasonably well, but it is very confusing when you need more control. A scale_units parameter could make it much easier to figure out how to manually set the scale. I will look into it. It might be trivial, it might not. Eric 
From: Eric Firing <efiring@ha...>  20091001 02:44:25

jasonsage@... wrote: > A couple of us are trying to figure out how to scale arrows in a quiver > plot so that we can exactly specify what the output arrows look like. > For example, we'd like to scale the vectors to half of their size, and > have it look like that on the quiver plot. > > So I tried even just getting a quiver plot to plot an arrow exactly as I > passed it, without it scaling anything. My attempt is this: > > import matplotlib.pylab as plt > fig=plt.figure(figsize=[6,6]) > q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy') I have committed a change to svn trunk, so that if you change the above to q = plt.quiver([0],[0], [1], [1], scale_units='xy', angles='xy', scale=1) it should do exactly what you want. When scale_units is given, the setting of "units" controls only the specification of the arrow width, so if you are not specifying the width, it doesn't have any effect. If I could start from scratch, I probably could come up with a better set of kwarg names and defaults; but for reasons of backwardscompatibility, this is what we have. The new scale_units kwarg makes it much easier to manually set the scale. Previously (and still with the default of scale_units=None), it was almost hopelessly confusing. (Maybe I should add "width_units", identical to "units", and deprecate the latter; this might make the meanings of the kwargs clearer.) Eric > ax=plt.axis([0,1.5,0,1.5]) > plt.grid(True) > plt.savefig('test.png') > > I'm trying to get the arrow to go from (0,0) to (1,1). However, with > units='x', it's just short, and with units='y', it's just a bit too > long. Furthermore, if I don't make the aspect ratio equal to one, I get > wild results since the xaxis and yaxis are different units then. It > would be really nice if there was a way to say units='data' (for data > coordinates), and then if scale=1, the arrows would be drawn with the > heads and tails at exactly the passed points. If scale=2, then each > arrow would be drawn exactly half of its length. I realize that > units='data' might mess up the other measurements of an arrow, though, > so maybe another parameter is called for, like a scale_units, that > defaults to units. > > What do people think? > > Thanks, > > Jason > > >  > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 912, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers 
From: <jasonsage@cr...>  20091001 04:05:27

Eric Firing wrote: > jasonsage@... wrote: >> A couple of us are trying to figure out how to scale arrows in a >> quiver plot so that we can exactly specify what the output arrows >> look like. For example, we'd like to scale the vectors to half of >> their size, and have it look like that on the quiver plot. >> >> So I tried even just getting a quiver plot to plot an arrow exactly >> as I passed it, without it scaling anything. My attempt is this: >> >> import matplotlib.pylab as plt >> fig=plt.figure(figsize=[6,6]) >> q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy') > > I have committed a change to svn trunk, so that if you change the > above to > > q = plt.quiver([0],[0], [1], [1], scale_units='xy', angles='xy', scale=1) > > it should do exactly what you want. When scale_units is given, the > setting of "units" controls only the specification of the arrow width, > so if you are not specifying the width, it doesn't have any effect. > > If I could start from scratch, I probably could come up with a better > set of kwarg names and defaults; but for reasons of > backwardscompatibility, this is what we have. The new scale_units > kwarg makes it much easier to manually set the scale. Previously (and > still with the default of scale_units=None), it was almost hopelessly > confusing. > > (Maybe I should add "width_units", identical to "units", and deprecate > the latter; this might make the meanings of the kwargs clearer.) > Thanks! Jason 
From: Christopher Barker <Chris.B<arker@no...>  20091001 18:45:04

Eric Firing wrote: > I have committed a change to svn trunk, so that if you change the > above to > > q = plt.quiver([0],[0], [1], [1], scale_units='xy', angles='xy', scale=1) Eric, You might recall that I spent a bit of time making a "stick plot" with quiver. I go to work OK, but I couldn't do exactly what I wanted. I think gets closer, but I"m not sure it quite gets there: How exactly are the arrows scaled with scale_units='xy'? What I'd like is for the length of the arrow to the the y scale only  the x scale it irrelevant (x is time, y is velocity). Can I do that with this? > (Maybe I should add "width_units", identical to "units", and deprecate > the latter; this might make the meanings of the kwargs clearer.) +1 But if you're doing that, you may want to make more changes, also  you might as well do them all at once. 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...>  20091002 01:17:59

Christopher Barker wrote: > Eric Firing wrote: >> I have committed a change to svn trunk, so that if you change the >> above to >> >> q = plt.quiver([0],[0], [1], [1], scale_units='xy', angles='xy', scale=1) > > Eric, > > You might recall that I spent a bit of time making a "stick plot" with > quiver. I go to work OK, but I couldn't do exactly what I wanted. I > think gets closer, but I"m not sure it quite gets there: > > How exactly are the arrows scaled with scale_units='xy'? What I'd like > is for the length of the arrow to the the y scale only  the x scale it > irrelevant (x is time, y is velocity). Can I do that with this? Yes, use scale_units='y'. And I think you will want angles='uv' for this. This result was already available via units='y', but it was awkward to figure out the scale kwarg itself. The advantage now is that with scale_units='y', and scale=1, an arrow with sqrt(u^2+v^2)==1 will be 1 yunit long. Eric > >> (Maybe I should add "width_units", identical to "units", and deprecate >> the latter; this might make the meanings of the kwargs clearer.) > > +1 > > But if you're doing that, you may want to make more changes, also  you > might as well do them all at once. > > Chris > 