Using "hold on" - bars do not have the same width

2 ビュー (過去 30 日間)
MiauMiau
MiauMiau 2017 年 9 月 2 日
回答済み: the cyclist 2017 年 9 月 3 日
Hi
I seem to have the strange problem that when I plot the following, the bars of the two histograms do not seem to have the same width:
hold on
[N,X] = hist(feature_1(:,1:5))
Bh = bar(X,N,'facecolor',[0.7 0.2 0.2]);
[A,Y] = hist(feature_2(:,1:5))
Bh = bar(Y,A,'facecolor',[0.3 0.6 0.2]);
hold off
Why is that? I have attached the feature_1, feature_2 files. Thanks

採用された回答

the cyclist
the cyclist 2017 年 9 月 3 日
Each call to the hist function is going to algorithmically choose the range and bin width, based on the data. You can specify the bins instead:
hist(feature_1(:,1:5),-10:2:15)
I would also recommend using the newer histogram command for this, if you have R2014b or later.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by