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

4 visualizaciones (últimos 30 días)
IM
IM el 15 de Jul. de 2020
Editada: dpb el 16 de Jul. de 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!

Respuestas (1)

dpb
dpb el 16 de Jul. de 2020
Editada: dpb el 16 de Jul. de 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)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by