Ryan May wrote: > John Hunter wrote: >> On Tue, Jul 15, 2008 at 5:37 PM, Ryan May <[EMAIL PROTECTED]> wrote: >> >>> I welcome any comments/criticism to help improve this. >> Hey Ryan, >> >> I have looked at this code briefly and have a few minor comments. I >> think Eric, who did the bulk of the current quiver implementation, and >> as an oceanographer is in a field much closer to yours than mine, will >> provide more useful feedback and should ultimately handle the patch >> submission.
I would be happy to do so. >> >> My first comment is that the code looks very good -- it is well >> thought out and commented, and t is definitely suitable for inclusion >> in the main line. Certainly the Barbs class can live in the >> collections module. You note in the driver code that you are worried >> about pollution of the axes namespace by including a domain specific >> method, and this is a reasonable worry, but the axes namespace is >> currently so polluted with plotting methods that it is a small worry. >> I think it would be fine for you to rework your code into a patch >> which provides the Barbs collection in matplotlib.collections, an Axes >> method, and a pyplot interface function (with a pylab module level >> docstring entry). The overloading of the Axes namespace is not ideal, >> but it's what we've got. > > Thanks. My question then is how do I add a pyplot interface, since it > appears from the comments that many of those are just generated boilerplate? If all that is needed is a standard wrapper, then you add an entry to the appropriate list in boilerplate.py (which is in the root mpl directory, alongside CHANGELOG etc.), and run it to generate all the boilerplate, and then substitute that output for the corresponding chunk at the end of pyplot.py. (Or do some variation on this procedure that gives the same end result.) > >> My second comment has to do with your comment at the end of the example: >> >> #Showing colormapping with uniform grid. Unfortunately, only the flags >> #on barbs get colormapped this way. >> >> On a cursory read of the code, it looks like you have implemented >> everything as a single poly collection, and the reason the flags only >> get colored is that the varicolored is black. It seems like there are >> two solutions: write your class as a combination of poly collection >> (for the flags) and line collection (for the barbs) and colormap both >> (there are some line collection colormapping examples in the examples >> subdir courtesy of Eric). The 2nd alternative, which I haven't >> explored, is to set the edgecolor equal to the facecolor and support >> colormapping of the edgecolors. Isn't this already done? Here is a Collections method: def set_edgecolor(self, c): """ Set the edgecolor(s) of the collection. *c* can be a matplotlib color arg (all patches have same color), or a sequence or rgba tuples; if it is a sequence the patches will cycle through the sequence. If *c* is 'face', the edge color will always be the same as the face color. ACCEPTS: matplotlib color arg or sequence of rgba tuples """ if c == 'face': self._edgecolors = 'face' else: if c is None: c = mpl.rcParams['patch.edgecolor'] self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha) And in the draw method: if self._edgecolors == 'face': edgecolors = self._facecolors else: edgecolors = self._edgecolors renderer.draw_path_collection( transform.frozen(), self.clipbox, clippath, clippath_trans, paths, self.get_transforms(), offsets, transOffset, self._facecolors, edgecolors, self._linewidths, self._linestyles, self._antialiaseds) Am I missing something? (Probably--I have not looked very closely at barb yet.) Eric > > Yeah, the comment went more to explain expected results. There was no > mystery to me why the edgecolors didn't get colormapped, it was pretty > clear from the collections code. I had started down the road of > combining lines and polygons in a PatchCollection, but that created a > bunch of separate objects for each wind barb that had to each be > transformed and have an offset applied. I took the lazy way out and > created (admittedly) degenerate polygons. :) I hadn't actually thought > (call it a brain fart) about actually going ahead and adding > colormapping for the edgecolors. Should I follow Mike's suggestion and > possibly take a go at adding it to the general Collections class? > (Granted, if someone else took a stab at it, it might land in SVN > sooner, I'm sure I still have a learning curve to go here). > >> Overall this is very promising, and I wish you the best trying to make >> mpl serviceble to the meteorology community. Jeff Whitaker has done a >> phenomenal job with basemap providing extensions for those needing >> cartographic projections as a toolkit. Depending on how far you want >> to go with meteorological support, we can include the changes in the >> mainline or fold them into a toolkit if they become hyper-specialized. > > I still have a few more things to add (on top of what Whitaker already > fixed for me): > > * Need to plot something (empty circle) for vector magnitude < 5. (I > did a plot the other day and was befuddled for a bit by seeing only 6 barbs) > * Need to fix support for masked arrays. The way the iteration goes > right now, masked values end up being iterated over, which is bad. > * Probably should add a set_uv(c) method, like quiver > > We'll see about the possibility of a toolkit. If I can keep up the > momentum, I might end up with significant functionality. I'd also have > to see how much of it really ends up being more than just simple example > scripts. And I agree, huge props to Whitaker for Basemap. Hopefully I > can get more people around me to use it instead of the abominations used > now. :) > > (I'd have things sooner if it weren't for the stupid Google CodeJam :) ) > > Ryan > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel