简体   繁体   中英

How to normalize Y axis in “histogram” function in matlab

I am using histogram command to plot 3 histogram in one figure and I have completed function with histogram command and I dont want to rewrite it for old hist command. However Im unable to normalize Y axis, because h.Values vector is read only.

h=histogram(data,'Normalization','pdf');
h.Values=(h.Values-min(h.Values))/(max(h.Values)-min(h.Values);

Can anybody help me? Thanks

EDIT after first comment: Yes I read matlab help. In the histogram image example I have PDF on Y axis, but values are from 0 to 3.5. I need to normalize from 0 to 1. When I use 'Normalization' parametr with 'probability' I get histogram from 0 to 0.3. I simply need PDF, but from 0 to 1. histogram example

You may use another 'new' function:

[y, x]=histcounts (x);
x=x(1:end-1)+diff(x/2)

Then you may normalize y as you wish. This function also has same normalize arguments as histogram.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM