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

4 ビュー (過去 30 日間)
IM
IM 2020 年 7 月 15 日
編集済み: dpb 2020 年 7 月 16 日
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 Center および File ExchangeGraphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by