from matplotlib import pyplot as plt import matplotlib import random a = [] for i in range(250): a.append(random.randint(80, 150)) # normed将频数分布变成频率分布直方图,20是组数 plt.hist(a, 20, normed=1) plt.show()