プロットのカスタマイズ

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で学ぶデータ可視化入門

linestyle の設定

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