8.11.2 ColorLegend class: A colorlegend is a colorscale divided in a number of subranges.

The ColorLegend class has this constructor:

class ColorLegend( colorscale,n)
Create a color legend dividing a colorscale in n subranges.

The full value range of the colorscale is divided in n subranges, each half range being divided in n/2 subranges. This sets n+1 limits of the subranges. The n colors of the subranges correspond to the subrange middle value.

ColorLegend objects have the following methods:

overflow( oflow=None)
Raise a runtime error if oflow == None, else return oflow.

color( val)
Return the color representing a value val.

The color is that of the subrange holding the value. If the value matches a subrange limit, the lower range color is returned. If the value falls outside the colorscale range, a runtime error is raised, unless the corresponding underflowcolor or overflowcolor attribute has been set, in which case this attirbute is returned. Though these attributes can be set to any not None value, it will usually be set to some color value, that will be used to show overflow values. The returned color is a tuple of three RGB values in the range 0-1.