Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
IM
IM am 15 Jul. 2020
Bearbeitet: dpb am 16 Jul. 2020
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!

Antworten (1)

dpb
dpb am 16 Jul. 2020
Bearbeitet: dpb am 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)

Kategorien

Mehr zu Graphics Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by