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?

 Réponse acceptée

Star Strider
Star Strider le 24 Mai 2020

0 votes

Set DisplayStyle to stairs.

5 commentaires

sani
sani le 24 Mai 2020
I did it, for some reason it not working
figure(1);
histogram(scint_single,'DisplayStyle','stairs','BinWidth',0.1);
set(gca,'YScale','log')
plot:
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.
.
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 le 24 Mai 2020
yes you are right, it was the bin number, thanks!
Star Strider
Star Strider le 24 Mai 2020
As always, my (our) pleasure!
Steven — Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by