%% Bar Chart with Colormap Colors
% Create a bar chart that uses colormap colors by setting the FaceColor property to 'flat'. Then set the CData property for each Bar object to an integer.

y = [1 3 5; 3 2 7; 3 4 2];
b = bar(y,'FaceColor','flat');
for k = 1:size(y,2)
    b(k).CData = k;
end

% Copyright 2012 The MathWorks, Inc.