How can I set up unequal bin widths in a histogram?

20 ビュー (過去 30 日間)
Brielle Paladino
Brielle Paladino 2022 年 6 月 22 日
回答済み: Image Analyst 2022 年 6 月 22 日
I need to generate a histogram with 3 buckets that are all values less than 1, all values between 1 and 8, and all values over 8 on the Y-axis.
Here is what I have so far:
CV = dlmread('F:\Thesis\ProcessedData\Isotope Data\Tritium\CentralValleyTritium.csv',',');
histogram(CV,3,"Normalization","probability","DisplayStyle","bar")
%xticks([])
yticks([0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1])
yticklabels(yticks*100)
title('Central Valley aquifer system');
ylabel('Frequency (%)');
xlabel('Tritium (T.U.)')

採用された回答

Michael
Michael 2022 年 6 月 22 日
編集済み: Michael 2022 年 6 月 22 日
Check out the 'BinEdges' argument.
blah = randi(20,1000,1);
histogram(blah,"Normalization","probability","DisplayStyle","bar","BinEdges",[-Inf 1 8 Inf])

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 6 月 22 日
You can define the edges however you want, like
data = -5 + 15* rand(100)
data = 100×100
2.6839 1.0885 0.2166 6.7288 9.9757 4.3848 -1.9736 3.5699 -4.9127 0.3137 8.9846 -0.9516 9.9937 -0.6472 6.0303 7.9143 5.6645 4.6707 0.7100 -2.4481 9.3626 4.1312 2.8955 6.7430 -3.5416 2.0600 -1.2510 -4.6499 5.3527 4.5358 9.7463 3.5891 -0.7346 1.0764 3.8193 0.3459 2.3773 5.6992 6.1882 3.5578 2.8017 -1.9078 1.4050 9.8717 -3.8653 6.8997 -2.7633 1.3472 7.1002 1.0631 -2.3439 7.7454 8.1984 6.8866 9.4258 -4.1720 0.7887 -0.5265 3.5278 -2.9247 -3.0393 9.5589 9.4857 -2.3953 7.0008 -3.0359 -0.3292 0.6567 7.3182 4.0836 2.6623 -4.0521 2.0639 3.8438 9.6554 1.9219 4.6090 5.8031 0.4196 3.6500 2.4549 9.0337 5.5198 7.9783 6.7668 4.5511 3.9563 -2.3751 4.8813 8.1491 0.3914 0.2047 4.0834 -4.4837 4.5208 9.1085 2.7801 3.4557 -3.2172 -0.3747 9.5773 -0.1624 0.1145 5.8870 5.1949 6.3222 3.1751 3.0506 -4.3706 -0.0430 7.5444 -0.3282 6.9952 -2.3318 4.5099 -4.5730 1.8700 -0.6243 4.1856 -0.1883 3.2194 0.8950 0.4606 1.2161 4.3896 9.6811 6.0795 -1.3887 7.8584 1.3511 3.8268 0.9500 1.7420 6.0183 9.0196 -4.8027 7.4267 5.7750 8.8808 2.7630 -3.9576 4.2206 -4.6981 7.7505 5.7921 -2.2016 -1.8446 -1.6631 -0.0446 7.4982 -2.6841 -1.7735 9.2936 7.8665 -1.5848 -2.0338 7.2456 6.7566 0.5880 6.2901 4.5479 4.2186 3.7011 -1.6837 -0.4349 -3.7618 6.2193 -3.6616 -3.4525 3.5226 2.8959 5.1305 -3.3875 9.8767 -2.4049 -1.1753 -1.8575 7.3723 0.7889 -0.8538 -2.7935 -1.1764 -0.2281 3.5841 -0.2219 0.1509 -3.0731 -3.0346 6.1594 1.2892 8.3167 8.5288 0.2179 8.5104 -1.5721 3.2089 -4.7439 -2.5708 0.3501 4.6048 7.1623 -3.8040 8.3821 5.1254 0.4447 -1.4890 -2.9940 5.8479 4.5807 3.0569 3.0895 5.3481 5.4764 -4.9492 -0.7947 6.5363 -2.9396 3.1270 -2.6494 -4.8051 -4.5377 7.7807 5.8562 3.9263 4.3998 0.4817 1.7592 0.9181 3.2542 0.0431 7.2630 2.2494 9.7040 7.8338 -4.4666 -2.1890 2.6193 -3.8943 6.9522 6.3134 -0.6133 8.8259 -1.0423 -4.4328 9.2538 -1.1699 3.8710 -4.3804 -3.4877 5.3002 -2.7956 0.1263 5.9630 6.7865 3.0746 -2.4189 -3.5154 1.7157 8.2477 3.6964 3.3085 5.7705 7.4845 9.4356 2.9944 -2.7716 -3.5858 8.9400 8.3067 1.8149 5.1462 5.3772 8.0653 -3.4847 -4.6762 9.5448 2.5996 -1.9430 -3.3800 5.0932 9.7581 -4.9908 8.1301 4.7823 -4.0592 1.1038 -0.0649 2.9142 2.8607 -1.8858 -0.5647 5.3794 8.2277 1.3505 2.6879 7.4774 0.0424 0.4956 6.8293 -4.2560
edges = [-inf, 0, 0.3, 0.4, 0.99, 8, inf] % or whatever...
edges = 1×7
-Inf 0 0.3000 0.4000 0.9900 8.0000 Inf
histObject = histogram(data, edges)
histObject =
Histogram with properties: Data: [100×100 double] Values: [3358 201 76 408 4600 1357] NumBins: 6 BinEdges: [-Inf 0 0.3000 0.4000 0.9900 8 Inf] BinWidth: 'nonuniform' BinLimits: [-Inf Inf] Normalization: 'count' FaceColor: 'auto' EdgeColor: [0 0 0] Show all properties
grid on;

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by