Small multiples

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

Ariel Rokem

Data Scientist

การเพิ่มข้อมูล

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

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

การเพิ่มข้อมูลเพิ่มเติม

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

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

และข้อมูลเพิ่มเติมอีก

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()
การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

ข้อมูลมากเกินไป!

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

Small multiples ด้วย plt.subplots

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

plt.show()

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

การเพิ่มข้อมูลลงใน subplots

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

plt.show()

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

Subplots พร้อมข้อมูล

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()
การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

Subplots พร้อมข้อมูล

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

การแชร์ช่วงแกน y

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

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

มาฝึกสร้าง subplots กันเถอะ!

การสร้างภาพข้อมูลด้วย Matplotlib เบื้องต้น

Preparing Video For Download...