Small multiples

Pengantar Visualisasi Data dengan Matplotlib

Ariel Rokem

Data Scientist

Menambahkan data

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"], 
        color='b')
ax.set_xlabel("Waktu (bulan)")
ax.set_ylabel("Presipitasi (inci)")
plt.show()

Pengantar Visualisasi Data dengan Matplotlib

Menambahkan lebih banyak data

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()

Pengantar Visualisasi Data dengan Matplotlib

Dan lebih banyak data

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()
Pengantar Visualisasi Data dengan Matplotlib

Kebanyakan data!

Pengantar Visualisasi Data dengan Matplotlib

Small multiples dengan plt.subplots

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

plt.show()

Pengantar Visualisasi Data dengan Matplotlib

Menambahkan data ke subplot

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

plt.show()

Pengantar Visualisasi Data dengan Matplotlib

Subplot dengan data

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("Presipitasi (inci)") ax[1].set_ylabel("Presipitasi (inci)")
ax[1].set_xlabel("Waktu (bulan)")
plt.show()
Pengantar Visualisasi Data dengan Matplotlib

Subplot dengan data

Pengantar Visualisasi Data dengan Matplotlib

Berbagi rentang sumbu-y

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

Pengantar Visualisasi Data dengan Matplotlib

Latihan membuat subplot!

Pengantar Visualisasi Data dengan Matplotlib

Preparing Video For Download...