Clear Filters
Clear Filters

How to change Y-axis in histfit plot from counts to percents?

2 views (last 30 days)
Dear All,
I have next plot :
h= histfit(myVec);
set(gca, 'XLim', [-2 2]);
ylim([0 400]);
set(h(2),'color','black');
How I can change this plot to plot with Y-axis in percentages not in counts ?
Thanks so much inadvance!

Answers (1)

dpb
dpb on 16 Jul 2020
Edited: dpb on 16 Jul 2020
hHF=histfit(myVec);
Vtot=sum(myVec);
arrayfun(@(h) set(h,'YData',h.YData/Vtot),hHF)
...
or, w/o the temporary,
hHF=histfit(myVec);
arrayfun(@(h) set(h,'YData',h.YData/sum(h.YData),hHF)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!