|
From: Eric F. <ef...@ha...> - 2009-09-30 02:33:30
|
jas...@cr... 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 x-axis and y-axis 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
|