Robert Hetland wrote:
Let me know if you would like to do a quick alpha test before you commit. I'll help to put it through the paces..
Thanks. Attached are a diff against svn and a test script to get you started. If you apply the diff as a patch, you should be able to call quiver2 from the pylab interface. Docstrings are provided. I made no attempt to copy the kwarg part of the API from the old quiver; this one is just too different. Most of the arg part of the API is the same, except that the optional third or fifth argument is a mappable array instead of a scale; I made the scale a kwarg, and it operates completely differently from the one in the old quiver--but for good reason, I think.
The key idea for the scale is that the "units" kwarg establishes a unit of measure ("arrow unit") for the arrows, and the scale gives the U,V data units per arrow unit. For example, if units="inches" and you have a 1 m/s velocity vector, then setting scale=2 will mean 2 m/s per inch, and the vector will be half an inch (assuming the figure dpi value is correct), regardless of how you change the window size or zoom. If units="x", and your x-axis goes from 0 to 50 km, then you might set scale=1/5.0 so that 1 m/s corresponds to 5 km along the x-axis; if you zoom in, the vector will grow. If units="width" (present default, though maybe not a good one), then the unit is the width of the plot, so you might make scale=50, so that 1 m/s makes an arrow 1/50th the width of the plot. Change the window width, and the arrow length changes along with it. Zoom, and it does not change, however. In all cases, the arrow direction remains constant, regardless of window or view limit manipulations. (This is all because of John's transform magic--it is a little hard to understand at first, but it certainly provides wonderful functionality.)
There is a simple auto-scaling algorithm, so one does not have to specify the scale kwarg initially.
Once quiver.py is in place, I will add related functionality such as ellipses, so you can plot mean velocities and standard error ellipses, for example.
One thing I have not looked into yet is what it will take to do all this correctly with polar axes and with basemap, which I will need.
quiver.diff (14.1 KB)
quiver2_demo.py (1.09 KB)