Is there a parameter in matplotlib/pandas to have the Y axis of a histogram as percentage?

后端 未结 5 2106
野趣味
野趣味 2020-12-13 02:12

I would like to compare two histograms by having the Y axis show the percentage of each column from the overall dataset size instead of an absolute value. Is that possible?

5条回答
  •  一个人的身影
    2020-12-13 02:50

    Looks like @CarstenKönig found the right way:

    df.hist(bins=20, weights=np.ones_like(df[df.columns[0]]) * 100. / len(df))
    

提交回复
热议问题