How to normalize a histogram in python?

前端 未结 5 1153
星月不相逢
星月不相逢 2021-02-12 11:35

I\'m trying to plot normed histogram, but instead of getting 1 as maximum value on y axis, I\'m getting different numbers.

For array k=(1,4,3,1)

 import         


        
5条回答
  •  醉话见心
    2021-02-12 12:00

    You could use the solution outlined here:

    weights = np.ones_like(myarray)/float(len(myarray))
    plt.hist(myarray, weights=weights)
    

提交回复
热议问题