フィルターのクリア

stacked bar graph from 3 columns

1 回表示 (過去 30 日間)
Frederick Awuah-Gyasi
Frederick Awuah-Gyasi 2022 年 5 月 27 日
編集済み: dpb 2022 年 5 月 27 日
I have this table T
T
X Y Z
1 0 5
1 1 3
1 2 3
2 0 6
2 1 0
2 2 7
how do I get a bar plot of Y stacked (X) vs Z (on the y axis) .
So it will be Y vs Z but Y will have two colors one for 1 and nother for 2.
  2 件のコメント
dpb
dpb 2022 年 5 月 27 日
Not at all clear what you really intend here, sorry...can you sketch what you think result should be and attach the image?
Frederick Awuah-Gyasi
Frederick Awuah-Gyasi 2022 年 5 月 27 日
@dpb pls find the image attached.

サインインしてコメントする。

採用された回答

dpb
dpb 2022 年 5 月 27 日
編集済み: dpb 2022 年 5 月 27 日
For 'stacked' the columns are sum of rows; there are as many bars as rows.
So, if your data array above is XYZ, then
Z=reshape(XYZ(:,3),3,[]);
bar(XYZ(1:3,2),Z,'stacked')
creates the orientation to produce what you've sketched.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by