How to force color mapping to a dynamic range larger than the particular input to imshow in matplotlib


Suppose I want to make 2+ heatmaps (on the same, or different Figures) and have the color<->value mapping be the same among them.

By default, the extreme values in the colormap (say jet) will be used for the dynamic range of each heatmap individually (i.e. each call to imshow), and I'd like to force the mapping to be the same, i.e. use the global dynamic range.

I think an equivalent statement is that I'd like to somehow specify an absolute mapping, whereas the behavior of imshow given a cmap object, is relative to the dynamic range of the input.

8/27/2012 3:37:11 PM

Accepted Answer

I think that this link may help?

Actually, this answer is much simpler.

5/23/2017 12:32:02 PM

If you don't want to specify the ranges but somehow you know that one plot has the largest range, you can get that range with['clim'] and set it for the other plots as I explained here: Imshow subplots with the same colorbar

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow