필터 지우기
필터 지우기

How to draw bar graph of different colors ?

조회 수: 215 (최근 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 !

채택된 답변

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일

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by