How to draw bar graph of different colors ?

231 vues (au cours des 30 derniers jours)
DEWDROP
DEWDROP le 25 Fév 2021
Commenté : Star Strider le 18 Jan 2024
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 !
  1 commentaire
darova
darova le 26 Fév 2021
What about using patch?

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 26 Fév 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.
  7 commentaires
Roger Breton
Roger Breton le 18 Jan 2024
This works for me!
RGB = xyz2rgb(testXYZ'/100);
figure
c = bar(R);
% set(gca, 'XTickLabel',{'CS0','CS10','CS20'})
ylim([0 100])
xlabel('Element')
ylabel('Score')
title('CIE 1995 TCS Score')
c.FaceColor = 'flat';
c.CData(1,:) = RGB(1,:);
c.CData(2,:) = RGB(2,:);
c.CData(3,:) = RGB(3,:);
Star Strider
Star Strider le 18 Jan 2024
@Roger Breton — Thank you!

Connectez-vous pour commenter.

Plus de réponses (1)

Adam Danz
Adam Danz le 26 Fév 2021

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by