Hi,
As promised, here's a patch to add wind barbs to matplotlib. This should addresses all of the comments I've received as well as all of the issues I previously mentioned. A synopsis of some of the updates:
1) Based on a conversation with Eric Firing, I've gone ahead and added the Barbs collection to quiver.py, which seems like a logical place.
2) Method added to set the data components.
3) Masked arrays are handled by saving all of the original arrays and using copies fed through delete_masked_points whenever the U/V are updated.
4) Setting the color of the edges/line portion of the barbs was easy, thanks to the setting of edgecolor='face' that Eric Firing pointed out. I guess this is a post 0.98.1 addition, since I don't have it in my system copy, only SVN. I also, for some reason, don't remember seeing the patch either. Anyhow, colormapping of the *whole* barb works now.
5) I added an empty circle marker for low wind speeds (vector magnitudes). Accomplishing having the unfilled circle while having the barbs filled involved a bit of a "elegant hack". Using the set of vertices that draws the CirclePolygon, I add an additional copy of these vertices, basically drawing the circle back the other way. This is basically tricking the drawing algorithm into drawing a really thin annulus with a very small gap, but it works perfectly as far as I can tell. It's also somewhat consistent with the way the lines on the barb are drawn. It is *far* simpler than any other solution, which would have required somehow mapping a color to each polygon *before* calling
draw_path_collection(). None of the backends I test had a problem, including PS, PDF, and SVG (tested with Evince, Firefox, and Acroread).
6) The relative sizes of components of the barb can be controlled by
passing a dictionary in through the sizes keyword parameter. The dictionary has keys 'spacing', 'height', 'width', 'emptybarb', which
map to values which are the size of these components relative to the length of the barb. I've also adjust some of the defaults a little so that tweaking shouldn't be needed (such as the issue Jeff raised). This seemed a lot better than passing around all of these parameters separately.
7)Driver demo code was moved to barb_demo.py under the pylab_examples. I loved Jeff's demo, but obviously that can only go in basemap.
The only issue I've seen is that scaling with PS is way too big. I've attached ps and pdf files from the same run to show the problem.
It should apply fine to SVN, but there are commented lines that should be switched with the ones there when set/get_offsets() are added to Collections.
Comments and Suggestions?
How do you guys manage committing only parts of your working copy, especially when you want to commit part of a file? I figure there's got to be a better way than multiple SVN checkouts and manually editing diffs.
Ryan
barbs_patch.diff (18.7 KB)
barbs.pdf (32.9 KB)
barbs.ps (45.5 KB)
···
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma