스몰 멀티플즈

Matplotlib으로 시작하는 데이터 시각화

Ariel Rokem

Data Scientist

데이터 추가

ax.plot(seattle_weather["MONTH"], 
        seattle_weather["MLY-PRCP-NORMAL"], 
        color='b')
ax.set_xlabel("시간 (월)")
ax.set_ylabel("강수량 (인치)")
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으로 시작하는 데이터 시각화

plt.subplots로 스몰 멀티플즈

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

plt.show()

Matplotlib으로 시작하는 데이터 시각화

서브플롯에 데이터 추가

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

plt.show()

Matplotlib으로 시작하는 데이터 시각화

데이터가 있는 서브플롯

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("강수량 (인치)") ax[1].set_ylabel("강수량 (인치)")
ax[1].set_xlabel("시간 (월)")
plt.show()
Matplotlib으로 시작하는 데이터 시각화

데이터가 있는 서브플롯

Matplotlib으로 시작하는 데이터 시각화

y축 범위 공유

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

Matplotlib으로 시작하는 데이터 시각화

서브플롯 실습

Matplotlib으로 시작하는 데이터 시각화

Preparing Video For Download...