Zane Selvans wrote: > Zane Selvans <[EMAIL PROTECTED]> writes: > >> I'm plotting a bunch of lines on a map. They're being colored >> according to the value of an attribute associated with the objects >> they represent, using a colormap. However, I also need to create a >> colorbar to act as a legend, describing what the colors of the lines >> means, in terms of values associated with that attribute. >> >> What's the easiest way to do that? > > I've found the matplotlib.colorbar.ColorbarBase class... and have been able to > use matplotlib.colorbar.make_axes() to create a somewhat acceptable set of > axes > into which I can put a colorbar constructed from the same colormap that I'm > using to color the lines I'm plotting. However, I can't seem to get the tics > and axes on the colorbar to correspond to the values associated with the > colors > - they only ever go from 0-1. I want them to go from, for instance, 0-180 > (degrees) in 20 or 30 degree intervals. It seemed like setting the keyword > arguments in ColorbarBase(boundaries=[0,180]) or values=linspace(0,180,10) or > something like that ought to have done the right thing... but no, and I don't > see any documentation on how these keywords are supposed to be used, in the > docstring or elsewhere... anyone know how they work?
You need to pass an instance of a matplotlib.colors.Normalize to the constructure to ColorbarBase, as in: cbar = ColorbarBase(norm=Normalize(0, 180)) As far as colormapping lines, you can do this using a LineCollection object. Hope this helps, Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ------------------------------------------------------------------------- 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-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users