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

6 次查看(过去 30 天)
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!

回答(1 个)

dpb
dpb 2020-7-16
编辑:dpb 2020-7-16
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)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by