Unterdiagramme

Einführung in die Datenvisualisierung mit Matplotlib

Ariel Rokem

Data Scientist

Daten hinzufügen

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"], 
        color='b')
ax.set_xlabel("Time (months)")
ax.set_ylabel("Precipitation (inches)")
plt.show()

Einführung in die Datenvisualisierung mit Matplotlib

Weitere Daten hinzufügen

ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-25PCTL"], 
        linestyle='--', color='b')
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-75PCTL"], 
        linestyle='--', color=color)
plt.show()

Einführung in die Datenvisualisierung mit Matplotlib

Noch mehr Daten

ax.plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-NORMAL"],
        color='r')
ax.plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-25PCTL"], 
        linestyle='--', color='r')
ax.plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-75PCTL"], 
        linestyle='--', color='r')
plt.show()
Einführung in die Datenvisualisierung mit Matplotlib

Zu viele Daten!

Einführung in die Datenvisualisierung mit Matplotlib

Unterdiagramme mit plt.subplots

fig, ax = plt.subplots()
fig, ax = plt.subplots(3, 2)

plt.show()

Einführung in die Datenvisualisierung mit Matplotlib

Daten zu Unterdiagrammen hinzufügen

ax.shape
(3, 2)
ax[0, 0].plot(seattle_weather["MONTH"], 
              seattle_weather["MLY-PRCP-NORMAL"], 
              color='b')

plt.show()

Einführung in die Datenvisualisierung mit Matplotlib

Unterdiagramme mit Daten

fig, ax = plt.subplots(2, 1)

ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-NORMAL"], color='b') ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-25PCTL"], linestyle='--', color='b') ax[0].plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-75PCTL"], linestyle='--', color='b')
ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-NORMAL"], color='r') ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-25PCTL"], linestyle='--', color='r') ax[1].plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-75PCTL"], linestyle='--', color='r')
ax[0].set_ylabel("Precipitation (inches)") ax[1].set_ylabel("Precipitation (inches)")
ax[1].set_xlabel("Time (months)")
plt.show()
Einführung in die Datenvisualisierung mit Matplotlib

Unterdiagramme mit Daten

Einführung in die Datenvisualisierung mit Matplotlib

Einheitlicher Wertebereich der y-Achse

fig, ax = plt.subplots(2, 1, sharey=True)

Einführung in die Datenvisualisierung mit Matplotlib

Zeit für ein paar Übungen!

Einführung in die Datenvisualisierung mit Matplotlib

Preparing Video For Download...