Plotting negative values on an histogram

24 ビュー (過去 30 日間)
Samuele Bolotta
Samuele Bolotta 2021 年 4 月 17 日
回答済み: Image Analyst 2021 年 4 月 17 日
I am plotting some values on an histogram.
figure
histogram('Categories',Categories,'BinCounts',[-72 -63 -54 -56],'BarWidth',0.5,'FaceColor','#EDB120')
xlabel('Membrane potential');
ylabel('Rest Memb Pot (mV)');
title('Amplitude of AP');
The problem is that whenever one of the values for BinCounts is negative, I get this error:
Error using histogram (line 156)
Expected input number 4, BinCounts, to be nonnegative.
While everything works perfectly if the values are all positive.

採用された回答

Image Analyst
Image Analyst 2021 年 4 月 17 日
Or maybe that's the data??? It doesn't make sense to have a negative count. If you want bars that go negative, use bar() not histogram().

その他の回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 4 月 17 日
It seems likely that you've mixed up BinCounts and BinEdges - it doesn't make much sense to have a negative number of something in a bin (perhaps in economics if we're talking about debts?).
HTH

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by