MATLAB: How to scale the range of a custom colormap correctly

colorcolor mapcolormapcustomcustom color mapcustom colormaprangescalescaling

I have made a custom colormap manually and I need it to be scaled from -1 to 1, in the result I got it is scaled from about -0.25 to 0.45.
This is the right scale for the custom colormap.
I have saved the variable of the colormap manually by inputting it to a variable. For example :
custom = [ 0 1 1
1 0 0
1 0 1];
How can I save it so that I could use the colormap like other presets anywhere, for example :
colormap(jet);

Best Answer

Use caxis(limits) to scale the colormap limits of the axes. I also recommend including the optional axis handle input (see documentation within the link).
More info on color scaling: