%% Reverse Colormap Order
% This example shows how to reverse the order of a colormap.
% Create a surface plot with the default colormap, parula. Add a colorbar to the figure to show the mapping of data values into the colormap.

figure
surf(peaks)
colorbar

%
% Use the colormap function to return the matrix of colormap values as map. Flip the order of the values in map using the flipud function. Then apply the new colormap to the figure.

map = colormap;
newmap = flipud(map);
colormap(newmap)

% The colorbar shows that the values in the colormap are reversed.
% Copyright 2015 The MathWorks, Inc.