Changing Color in Stack bar

1 view (last 30 days)
Prasad Joshi
Prasad Joshi on 12 Apr 2022
Answered: Prasad Joshi on 12 Apr 2022
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')

Accepted Answer

Prasad Joshi
Prasad Joshi on 12 Apr 2022
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')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!