How do I make a legend for Line2D objects in Basemap, colored using a colormap?

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 know what the upper and lower bounds of the values that need to be represented in the colorbar are, but I don't see any way to just slap a generic colorbar on the figure and give it some tick marks corresponding to the values I know the colors represent.

I have a list of all the Line2D objects in the map, but I can't pass them to colorbar() as the 'mappable' parameter without getting:

AttributeError: 'Line2D' object has no attribute 'autoscale_None'

It seems like this is something that should be trivially easy, but I don't see how to do it in the documentation anywhere.

Thanks for any insight you might have...



Zane Selvans
Amateur Earthling
PGP Key: 55E0815F