Stuart’s MATLAB Videos

Watch and Learn

Interactively editing a colormap in MATLAB 1

Posted by Doug Hull,

I recently wanted a colormap that was distinctive. I wanted the zero values to be one color while the negative and positive values were different shades. This video shows how to do this interactively. The skills shown here work for lots of different colormap tasks.

After I did this manually, I found there was a MATLAB File Exchange file that does this kind of thing for you.

1 CommentsOldest to Newest

Matteo replied on : 1 of 1
Hi Doug My pedestrian solution takes just a few lines of code. I use the signed most negative and most positive values from the data and sum them. Then I use both the numerical result and its sign to assign the limits automatically. This should anchor the white of the colorbar to zero. This is a demonstrative pseudocode: D = maxpos+maxneg if D >0 % abs (maxpos) > abs (maxneg) clim=[maxneg (maxpos-D)] elseif D <0 clim=[(maxneg-D) maxpos] end In your case maxpos=8 and maxneg=-6