積み上げ棒グラフの色を変える方法

15 views (last 30 days)
qrqr
qrqr on 18 Mar 2020
Edited: Jiro Doke on 19 Mar 2020
以下の積み上げ棒グラフがあります。
A=[1 2 3; 4 5 6;5 8 9];
bar(A,"stacked");
このグラフの色を変更したいのですが、どのようにするのでしょうか?
下から赤、青、黒 で色を変えたいと思っています。
よろしくお願いします。

Accepted Answer

michio
michio on 18 Mar 2020
Edited: michio on 18 Mar 2020
それぞれ別々の bar オブジェクトが作られるので・・ひとまず以下のようにすれば色を変えることができます。
A=[1 2 3; 4 5 6;5 8 9];
h_bar = bar(A,"stacked");
h_bar(1).FaceColor = 'red';
h_bar(2).FaceColor = 'blue';
h_bar(3).FaceColor = 'black';
  1 Comment
qrqr
qrqr on 18 Mar 2020
ありがとうございます。

Sign in to comment.

More Answers (1)

Jiro Doke
Jiro Doke on 18 Mar 2020
Edited: Jiro Doke on 19 Mar 2020
棒グラフ(bar)のオブジェクトをいじると、色などを変更することができます。
A=[1 2 3; 4 5 6;5 8 9];
b = bar(A,"stacked");
b(1).FaceColor = "r";
b(2).FaceColor = "b";
b(3).FaceColor = "k";
  3 Comments
qrqr
qrqr on 18 Mar 2020
ありがとうございます。
Jiro Doke
Jiro Doke on 18 Mar 2020
失礼しました。(笑)

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!