Define bar plot colors with CData for different data series

21 views (last 30 days)
I have data for three different measurements and I'd like to plot them in a bar graph. This works with the bar command:
s2 = [ na2 , nb2 , nc2 ];
figure;
b1 = bar(pulse2,s2,'hist','FaceColor','flat');
ni2 are vectors with the data points. Now I'd like to define the color for each series with RGB Triplets.
I know that I can access this property with b1.CData, because the FaceColor is set to flat, but I do not know how. How should the line
b1.CData(:,:) = ([0.1600 0.4400 1] [0.9300 0 0] [0.00 0.57 0.00])
Actually look like to have all the bars for series one in the color [0.1600 0.4400 1], all the bars for series two with color [0.9300 0 0] and all the bars for series three with [0.00 0.57 0.00]?
Thank you very much in advance!

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!