Stacked bar plot with negative value
5 ビュー (過去 30 日間)
古いコメントを表示
Hello, I need to make stacked bar plot with my data to look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161860/image.png)
My data set:
data1 = [0 0 3.16 25.08 46.87 57.97 39.25 28.81 10.63 0.06 0 0]
data2 = [74.00 152.68 319.99 514.05 635.73 647.61 645.32 569.51 398.48 226.13 84.88 52.08]
data3 = [628.07 497.66 426.97 285.56 220.67 184.04 212.71 239.93 318.25 451.61 545.02 626.39]
If I make it like this:
x = 1:12;
y = [data2' data1' data3'];
bar(x,y,'stacked')
It looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161861/image.png)
So I need to green part be like negative values.
y = [data2' -data1' data3'];
and graph then look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161863/image.png)
How to get green part to negative side of y axe?
Thank you for advice.
0 件のコメント
採用された回答
Star Strider
2017 年 3 月 18 日
Try this:
x = 1:12;
y1 = [data2' data3'];
bar(x,y1,'stacked')
hold on
bar(x, -data1, 'g')
hold off
6 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!