The colorbar can be attributed to a subimage in the figure using the colormap function. To set the range of the colormap indexed by the colorbar, set its 'YLim' property to this range.
The following code illustrates this concept:
load trees
subplot(1,2,1);
subimage(X,map);
subplot(1,2,2);
subimage(X,winter(64));
fullmap = [map;winter];
colormap(fullmap);
colorbar('YLim',[size(map,1), size(map,1)+64]);
Best Answer