Changing Color in Stack bar

4 ビュー (過去 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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by