绘制直方图

Python 数据科学入门

Hillary Green-Lerman

Lead Data Scientist, Looker

追踪绑匪

Python 数据科学入门

什么是直方图?

Python 数据科学入门

用 matplotlib 绘制直方图

plt.hist(gravel.mass)

plt.show()

Python 数据科学入门

调整箱数

plt.hist(data, bins=nbins)
plt.hist(gravel.mass, bins=40)

Python 数据科学入门

调整范围

plt.hist(data,
         range=(xmin, xmax))
plt.hist(gravel.mass,
         range=(50, 100))

Python 数据科学入门

归一化

未归一化的柱状图

plt.hist(male_weight)
plt.hist(female_weight)

柱面积之和 = 1

plt.hist(male_weight, density=True)
plt.hist(female_weight, density=True)

Python 数据科学入门

让我们练习!

Python 数据科学入门

Preparing Video For Download...