I have data in Matlab for which I want to create a heat map style graph. The usual way to do this is with imagesc
and possibly a custom color map. (See, for example, the accepted answer on this question: MATLAB heat map.) If the data contains NaNs, however, this does not necessarily do what I want. The MathWorks Documentation claims that the behavior is undefined for NaN. In practice, the result seems to be that the color is assigned that of the smallest value in your color map.
In cases where the NaN is marking that no value was available, this can be misleading. It would be preferable to have this show as something other than the colors in the color map. How to do it?
I note this other question (Assign different color to NaN values in Matlab images), which is somewhat similar. In my view that's not a duplicate, however, because it creates the image via a different function call, potentially with its own underlying structures.