I believe caxis is the team you are looking for. Using:
caxis([minValue maxValue])
Using caxis like this, all values โโoutside the range [minValue maxValue] will be colored with the lowest or highest value in the color palette, respectively.
Since colorbar and friends use colormap , you will need to adjust the current color palette if you want to adjust the number of colors used. Do it like this:
%# get current colormap map = colormap; %# adjust for number of colors you want rows = uint16(linspace(1, size(map,1), NUM_COLORS)) ; map = map(rows, :); %# and apply the new colormap colormap(map);
Of course, combining this with caxis is the most powerful.
If you do not want to show some values โโoutside the range, this is not a task for colorbar or caxis , which is up to you - you will have to configure the data that was built so that all the values โโyou do not want the graph to be NaN . This will allow Matlab to understand that you do not want to build this data:
data( indices_to_data_not_to_plot ) = NaN; surf(x,y,data); %
source share