据我所知,matplotlib
没有内置此功能。但是,复制起来很容易
import numpy as np
heights,bins = np.histogram(data,bins=50)
heights = heights/sum(heights)
plt.bar(bins[:-1],heights,width=(max(bins) - min(bins))/len(bins), color="blue", alpha=0.5)
编辑:这是来自类似问题的另一种方法:
weights = np.ones_like(data)/len(data)
plt.hist(data, bins=50, weights=weights, color="blue", alpha=0.5, normed=False)