How to draw bar graph of different colors ?

179 views (last 30 days)
I have plotted the bar graph but the color is same. i want to differentiate the color of each x variable .Thank you in advance !

Accepted Answer

Star Strider
Star Strider on 26 Feb 2021
Try this:
y = [280 260 240];
figure
c = bar(y);
set(gca, 'XTickLabel',{'CS0','CS10','CS20'})
xlabel('Wt% of cenospheres')
ylabel('Workability, mm')
c.FaceColor = 'flat';
c.CData(1,:) = [1 0 0];
c.CData(2,:) = [0 1 0];
c.CData(3,:) = [0 0 1];
producing:
Experiment with different colours.
  5 Comments

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 26 Feb 2021

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by