Changing Color in Stack bar

조회 수: 2 (최근 30일)
Prasad Joshi
Prasad Joshi 2022년 4월 12일
답변: Prasad Joshi 2022년 4월 12일
Hello ,
Can someone suggest how can i changed color in stack bar . for example first red, second blue & third green . Can someone suggests any changes in code thanks in advance .By the way I am using Matlab 2016B
r=xlsread('Master_data.xlsx','B2:E10')
i=1
C(1,:)=[r(i+1) r(i+10) r(i+19) r(i+28) r(i+2) r(i+11) r(i+20) r(i+29)]
C(2,:)=[r(i+4) r(i+13) r(i+22) r(i+31) r(i+5) r(i+14) r(i+23) r(i+32)]
C(3,:)=[r(i+7) r(i+16) r(i+25) r(i+34) r(i+8) r(i+17) r(i+26) r(i+35)]
D(1,:)=C(1,:)
D(2,:)=C(2,:) -(C(1,:))
D(3,:)=C(3,:)-(C(2,:))
D=D'
h=bar(D,'stacked')

답변 (1개)

Prasad Joshi
Prasad Joshi 2022년 4월 12일
Hi if anyone need used following code. add this to the code
set(h(1),'Facecolor','red')
set(h(2),'Facecolor','blue')
set(h(3),'Facecolor','green')

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by