Sometimes you are bound to plot 2D real functions with a big positive maximum and a small (in comparison) negative minimum. In case you use a colormap like ‘jet’ you must be aware of two things:

- Jet/Rainbow is usually a bad choice for colormap for several reasons.
- The reader must infer which color corresponds to the zero value and then interpret where in the plot the values are negative and where positive.

The first problem can be avoided using ‘hot’ or ‘gray’ colormaps, but the second one can’t be solved with conventional colormaps.

The Polarmap function uploaded to FileExchange propose a clean solution – shade an existing colormap to place the white color in the value corresponding to the zero value. This is convenient because the reader then does not have to infer the zero value, since it is always white.

Nevertheless, there is still one problem when the z-axis of your data is not symmetric, i.e., when the maximum and minimum does not have similar absolute values. In such cases, the smaller extreme can end up washed away from the plot.

But not all is lost! If your main purpose is to demonstrate there is a negative part that is not negligible you can generate a colormap that is linear from zero to the maximum and linear from zero to the minimum.

This plot has the disadvantage that an unkeen reader might think that the positive maximum and negative minimum are of the same order. Including a colorbar like the one on the right side of the figure should avoid most confusion, while highlighting that there is a non-negligible negative part in the figure.

The last figure was plotted using the following Matlab code:

figure('color', 'white'); imagesc(X*1E3, Y*1E3, WDX0); colormap(NegativeEnhancingColormap(128, [min(WDX0(:)) max(WDX0(:))], ... [0 0 1], [1 0 0], 1)); colorbar; axis image xy; xlabel('x (mm)'); ylabel('p·s^2 (mm)');

where the NegativeEnhancingColormap function is a personal function that I release under a Creative Commons Attribution-ShareAlike 3.0 Unported License. You can download it for Matlab using the following links:

**Version 1.0**: Download

Thanks

Thanks for this. I have made some modifications to allow the supplied data matrix to contain only positive, or only negative elements, if this is of interest:

http://www.cs.bham.ac.uk/~pxw869/codedata/NegativeEnhancingColormap.m

The power does not work. It gives me a range outside [0 1]

Also, changing the number of colors, N, alters where “0” is defined in the data. I’d be very careful using this function.

Thank you!