how can I present histogram as line plot

Hi,
I want to present histogram as the picture added, does anyone knows what is the commend?

 採用された回答

Star Strider
Star Strider 2020 年 5 月 24 日

0 投票

Set DisplayStyle to stairs.

5 件のコメント

sani
sani 2020 年 5 月 24 日
I did it, for some reason it not working
figure(1);
histogram(scint_single,'DisplayStyle','stairs','BinWidth',0.1);
set(gca,'YScale','log')
plot:
Star Strider
Star Strider 2020 年 5 月 24 日
It is working.
It is doing exactly what you asked it to do. The histogram data appear to be going to 0 between the other bins in that plot.
This produces a result similar to what you originally described as wanting it to look like:
x = rand(1, 100);
histogram(x, 10, 'DisplayStyle','stairs')
Perhaps requesting fewer bins will give you the result that you originally described.
.
Steven Lord
Steven Lord 2020 年 5 月 24 日
Zoom in. You've got bins of width 0.1 spanning from (roughly) 0 to 3500 on the X axis. That means you have roughly 35000 bins. What's the horizontal resolution of your computer screen?
My guess is that some of those bins contain data and some are empty. You've probably got something that looks like this but with much narrower bins and many more bins.
histogram('BinCounts', repmat([5 0], 1, 10), ...
'BinEdges', 0:20, ...
'DisplayStyle', 'stairs')
ylim([-1 6])
To paraphrase Roy Scheider in the movie Jaws, I think you're gonna need bigger (wider) bins. Or a bigger (higher resolution) screen.
sani
sani 2020 年 5 月 24 日
yes you are right, it was the bin number, thanks!
Star Strider
Star Strider 2020 年 5 月 24 日
As always, my (our) pleasure!
Steven — Thank you!

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2020 年 5 月 24 日

コメント済み:

2020 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by