Current technical definitions
Colormaps define a mapping from the range [0…1] to color values
Norms define a mapping from data coordinates to [0…1]
- Colorbars draw the whole colormap (i.e. the colors mapped from [0…1]).
Keep the colormapping to data space as is but limit the colorbar to the range blue-orange.
Current solution: Create a new norm and colormap
A. Complicated to create.
B. For diverging colormaps the color at the center of the cmap range (=0.5) is a special value. This feature gets lost in the rescaling. It replaced by a fine-tuned balance between the Norm and the Colorma (in the example norm: 0 -> 0.66, and cmap(0.66) is the sepecial value). It’s not easily possible anymore later on to exchange the colormap without regenerating the norm.
Option 1: Improved factory API
Come up with some Norm and Colormap factory API that creates these. Solves A, but not B.
Option 2: Support setting cbar limits
This gives up 3) Colorbars draw the whole colormap.
What colors should values beyond the cbar limits have?
- Their cmap values? - I find this problematic because the image would contain values that are not in the colorbar, e.g. for the above example and limiting the cbar to orange, how should a user interpret red?
- The over/under values? - Might be difficult to implement because the color calculation of the image is done in the cmap, but the clipping is done on the Axes. The axes would have to notify the colormap on the restriction. But what if two axes use the same colormap for two images but clip at different values?
Option 3: Add
under_lim attributes to the cmap
a value of
over_lim=0.75 would map values >0.75 to the over color.
We would define:
3) Colorbars draw the (possibly clipped) colormap (i.e. the colors mapped from [under_lim…overlim]).