MATLAB: Question for color set in colorbar

colorcolorbarcolormapfunctionimagescmapmatlab functionmatrixplotplotting

Hello,
I plot an image using imagesc, and the colorbar is automatically set from blue (lowest value, e.g. 0) to red (highest value, e.g. 1). Is there a way to set the interval color from white (lowest value) to red (highest value) ?
Thanks

Best Answer

You can also create you custom colormap
White = [1 1 1];
Red = [1 0 0];
t = linspace(0,1,100)';
cmap = Red.*t + White.*(1-t);
colormap(cmap);
colorbar