In matlab versions prior to 2014 I could alter the underlying image in the colorbar by doing the following:
cmap = ... % something which is MxNx3
colormap(reshape(cmap, [N*M,3]))
cmapIxs2D = reshape((1:(N*M))', [N, M]);
ax = colorbar('peer', gca);
set(get(ax, 'Children'), 'CData', cmapIxs2D);
ylim(ch, [0 255]), xlim(ch, [0 1])
This was useful if you wanted to display a custom colormap which is e.g. 2D (NxMx3) instead of the normal 1D (Nx3). How could this be done in versions after 2014 where the underlying image of the colorbar is no longer accesible, it has no Children according to the documentation.
Example (Color value is interpreted as having a e.g. velocity(y-axis-color) and acceleration(x-axis-color)) :