What would the bar graph coding be?

6 ビュー (過去 30 日間)
AbelM Kusemererwa
AbelM Kusemererwa 2015 年 7 月 14 日
コメント済み: Star Strider 2015 年 7 月 14 日
Histo1 is a 6 column data. When click on bar graph (the image attached is displayed). How can I code it to also include text for each group of bars?

採用された回答

Star Strider
Star Strider 2015 年 7 月 14 日
I am not certain what you want, so here are two possibilities:
D = load('histo1.mat');
histo1 = D.histo1;
figure(1)
bar(histo1);
set(gca, 'XTickLabel', {'Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5', 'Group 6'})
figure(2)
bar(histo1);
legend('Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5', 'Group 6')
Be sure to look at both figures! The code in each labels the ‘group’ data differently.
  2 件のコメント
AbelM Kusemererwa
AbelM Kusemererwa 2015 年 7 月 14 日
The first is good for me but how do I inclined the groups?
Star Strider
Star Strider 2015 年 7 月 14 日
Do you want the labels at an angle to the horizontal? If you have R2014b or later, this is relatively easy. If you have an earlier version, it is still possible but more difficult.
The R2014b and later code:
D = load('AbelM Kusemererwa histo1.mat');
histo1 = D.histo1;
figure(1)
bar(histo1);
set(gca, 'XTickLabel', {'Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5', 'Group 6'}, 'XTickLabelRotation',30)
The rotation is in degrees, so experiment with it to get the result you want.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by