how to use histogram(data, num_bins)?

I have a 8945x1 double array, and I want to view it as a histogram
first try: histogram(data), here's what I get:
second try: using histogram(data, 20):
what am I doing wrong?
data is attached as an excel file if anybody cares to investigate
thanks!

 採用された回答

Ahmet Cecen
Ahmet Cecen 2016 年 4 月 14 日

0 投票

You don't appear to be doing anything wrong. Your data is the problem:
1417.69
521.83
15.23
8.28
7.05
The plot shows exactly what it should: and infinitesimal 1 count at around 1400 and 520, and a gigantic peak at around 0-15 range, since all of your data falls in to that range. Try:
histogram(data(5:end), 20);
and you will be able to see what I mean.

3 件のコメント

59morgan
59morgan 2016 年 4 月 14 日
thanks for your help. I understand what you mean, about the data spread being a problem, but shouldn't increasing the number of bins give me a decent view? even up to maybe 50 bins? the idea is not to exclude the outliers but to see them alongside the others
59morgan
59morgan 2016 年 4 月 14 日
ok, so, what's going on is, it looks like just one big bin because there are many bins out to the right but I can't see them because they have such small counts... so how would you suggest I visualize this distribution, given that leaving out any data defeats the purpose? thanks
Ahmet Cecen
Ahmet Cecen 2016 年 4 月 14 日
You can:
- Take log10 of your data and visualize that using histogram. Change your x label appropriately.
- Overlay them manually: take hist of data(1:50), then data(5:end). Crop and overlay the two figures. You will sacrifice accuracy but the message will get through.
- Manually plot the histogram as a bar plot, after using histogram to grab the counts. You can now get rid of the empty space between the 1400 value and 10 values, although x axis is no longer a coordinate system, simply a label.

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

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by