Changing Color in Stack bar

2 次查看(过去 30 天)
Prasad Joshi
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