量化比較:散佈圖

Matplotlib 資料視覺化入門

Ariel Rokem

Data Scientist

認識散佈圖

fig, ax = plt.subplots()

ax.scatter(climate_change["co2"], climate_change["relative_temp"])
ax.set_xlabel("CO2 (ppm)") ax.set_ylabel("Relative temperature (Celsius)") plt.show()

Matplotlib 資料視覺化入門

自訂散佈圖

eighties = climate_change["1980-01-01":"1989-12-31"]
nineties = climate_change["1990-01-01":"1999-12-31"]

fig, ax = plt.subplots()
ax.scatter(eighties["co2"], eighties["relative_temp"], color="red", label="eighties")
ax.scatter(nineties["co2"], nineties["relative_temp"], color="blue", label="nineties")
ax.legend() ax.set_xlabel("CO2 (ppm)") ax.set_ylabel("Relative temperature (Celsius)") plt.show()
Matplotlib 資料視覺化入門

用顏色編碼比較

Matplotlib 資料視覺化入門

用顏色編碼第三變數

fig, ax = plt.subplots()

ax.scatter(climate_change["co2"], climate_change["relative_temp"], c=climate_change.index)
ax.set_xlabel("CO2 (ppm)") ax.set_ylabel("Relative temperature (Celsius)") plt.show()
Matplotlib 資料視覺化入門

以顏色表達時間

Matplotlib 資料視覺化入門

一起來練習吧!

Matplotlib 資料視覺化入門

Preparing Video For Download...