continous colormap with 'plateau'

Hi everyone,

is it possible to map a certain range within the value-range of a image plot to
a constant value? Currently I am overlaying a filled contour plot with just two
contour levels on top of an image plot. This works, but I would like to display
the plateau in the colorbar as well, so that the color changes continously over
the whole value range but in the specified range where it should remain white.
I guess I would need a special colormapper to achieve that.

Thanks in advance for any pointers, Christian

Christian K. wrote:

Hi everyone,

is it possible to map a certain range within the value-range of a image plot to a constant value? Currently I am overlaying a filled contour plot with just two contour levels on top of an image plot. This works, but I would like to display the plateau in the colorbar as well, so that the color changes continously over the whole value range but in the specified range where it should remain white. I guess I would need a special colormapper to achieve that.

Yes. See http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html
for an explanation of how to make one.

Actually, you can achieve what you want with either a special cmap, or with a special norm. I don't think we have any examples of the latter.

Eric

Eric Firing schrieb:

Christian K. wrote:

Hi everyone,

is it possible to map a certain range within the value-range of a image plot to a constant value? Currently I am overlaying a filled contour plot with just two contour levels on top of an image plot. This works, but I would like to display the plateau in the colorbar as well, so that the color changes continously over the whole value range but in the specified range where it should remain white. I guess I would need a special colormapper to achieve that.

Yes. See http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html
for an explanation of how to make one.

Actually, you can achieve what you want with either a special cmap, or with a special norm. I don't think we have any examples of the latter.

Tahsnk, Eric. I know understand how to create a discontinous colormap. However I cannot think of an elegant way how to map the data value range to the [0,1] color map range so that always the _value_ range between e.g. 0.41 and 0.43 will be displayed white regardless of the lower and upper bounds of the data value range.

Regards, Christian

Christian K. wrote:

Eric Firing schrieb:

Christian K. wrote:

Hi everyone,

is it possible to map a certain range within the value-range of a image plot to a constant value? Currently I am overlaying a filled contour plot with just two contour levels on top of an image plot. This works, but I would like to display the plateau in the colorbar as well, so that the color changes continously over the whole value range but in the specified range where it should remain white. I guess I would need a special colormapper to achieve that.

Yes. See http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html
for an explanation of how to make one.

Actually, you can achieve what you want with either a special cmap, or with a special norm. I don't think we have any examples of the latter.

Tahsnk, Eric. I know understand how to create a discontinous colormap. However I cannot think of an elegant way how to map the data value range to the [0,1] color map range so that always the _value_ range between e.g. 0.41 and 0.43 will be displayed white regardless of the lower and upper bounds of the data value range.

It sounds like you really need to make a custom subclass of Normalize; see the source for Normalize in mpl's colors.py to get an idea of what is required.

Eric

ยทยทยท

Regards, Christian