How to draw bar graph of different colors ?

226 ビュー (過去 30 日間)
DEWDROP
DEWDROP 2021 年 2 月 25 日
コメント済み: Star Strider 2024 年 1 月 18 日
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 件のコメント
darova
darova 2021 年 2 月 26 日
What about using patch?

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2021 年 2 月 26 日
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 件のコメント
Roger Breton
Roger Breton 2024 年 1 月 18 日
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 2024 年 1 月 18 日
@Roger Breton — Thank you!

サインインしてコメントする。

その他の回答 (1 件)

Adam Danz
Adam Danz 2021 年 2 月 26 日
  1 件のコメント
DEWDROP
DEWDROP 2021 年 2 月 28 日
Thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by