プロットのカスタマイズ

Matplotlib によるデータ可視化入門

Ariel Rokem

Data Scientist

データの表示のカスタマイズ

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"])
plt.show()

Matplotlib によるデータ可視化入門

マーカーを追加する

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"], 
        marker="o")
plt.show()

Matplotlib によるデータ可視化入門

マーカーの選択

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"], 
        marker="v")
plt.show()

https://matplotlib.org/api/markers_api.html

Matplotlib によるデータ可視化入門

線種の設定

fig, ax = plt.subplots()
ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-TAVG-NORMAL"],
        marker="v", linestyle="--")
plt.show()

Matplotlib によるデータ可視化入門

linestyleで線を消去する

fig, ax = plt.subplots()
ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-TAVG-NORMAL"],
        marker="v", linestyle="None")
plt.show()

Matplotlib によるデータ可視化入門

色の選択

fig, ax = plt.subplots()
ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-TAVG-NORMAL"],
        marker="v", linestyle="--", color="r")
plt.show()

Matplotlib によるデータ可視化入門

軸ラベルのカスタマイズ

ax.set_xlabel("Time (months)")
plt.show()

Matplotlib によるデータ可視化入門

y軸ラベルの設定

ax.set_xlabel("Time (months)")
ax.set_ylabel("Average temperature (Fahrenheit degrees)")
plt.show()

Matplotlib によるデータ可視化入門

タイトルを追加する

ax.set_title("Weather in Seattle")
plt.show()

Matplotlib によるデータ可視化入門

プロットのカスタマイズを練習しよう!

Matplotlib によるデータ可視化入門

Preparing Video For Download...