Anpassa dina diagram

Introduktion till datavisualisering med Matplotlib

Ariel Rokem

Data Scientist

Anpassa datautseendet

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

Introduktion till datavisualisering med Matplotlib

Lägga till markörer

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

Introduktion till datavisualisering med Matplotlib

Välja markörer

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

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

Introduktion till datavisualisering med Matplotlib

Ange linjestil

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

Introduktion till datavisualisering med Matplotlib

Ta bort linjer med linestyle

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

Introduktion till datavisualisering med Matplotlib

Välja färg

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

Introduktion till datavisualisering med Matplotlib

Anpassa axelns etiketter

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

Introduktion till datavisualisering med Matplotlib

Ange y-axelns etikett

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

Introduktion till datavisualisering med Matplotlib

Lägga till en titel

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

Introduktion till datavisualisering med Matplotlib

Nu kör vi en övning!

Introduktion till datavisualisering med Matplotlib

Preparing Video For Download...