繪製長條圖

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...