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

后端 未结 5 2105
野趣味
野趣味 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 02:48

    I know this answer is 6 years later but to anyone using density=True (the substitute for the normed=True), this is not doing what you might want to. It will normalize the whole distribution so that the area of the bins is 1. So if you have more bins with a width < 1 you can expect the height to be > 1 (y-axis). If you want to bound your histogram to [0;1] you will have to calculate it yourself.

提交回复
热议问题