y축을 공유하는 스몰 멀티플
스몰 멀티플을 만들 때는 서로 다른 플롯의 y축 스케일을 동일하게 맞추는 것이 좋을 때가 많습니다. 이를 위해 sharey 키워드를 True로 설정하면 됩니다.
이 연습 문제에서는 y축을 공유하는 두 개의 Axes 객체가 있는 Figure를 만듭니다. 이전과 마찬가지로 데이터는 seattle_weather와 austin_weather DataFrame에 제공됩니다.
이 연습은 강의의 일부입니다
Matplotlib으로 시작하는 데이터 시각화
연습 안내
- y축 범위를 공유하는 두 개의 Axes 객체 배열을 가진 Figure를 생성하세요.
- 위쪽 Axes에 시애틀의
"MLY-PRCP-NORMAL"을 파란 실선으로 그리세요. - 위쪽 Axes에 시애틀의
"MLY-PRCP-25PCTL"과"MLY-PRCP-75PCTL"을 파란 점선으로 추가하세요. - 아래쪽 Axes에 오스틴의
"MLY-PRCP-NORMAL"을 빨간 실선으로, 그리고"MLY-PRCP-25PCTL"과"MLY-PRCP-75PCTL"을 빨간 점선으로 그리세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a figure and an array of axes: 2 rows, 1 column with shared y axis
fig, ax = plt.subplots(2, 1, sharey=True)
# Plot Seattle precipitation data in the top axes
____.plot(____, ____, color = ____)
____.plot(____, ____, color = ____, linestyle = ____)
____.plot(____, ____, color = ____, linestyle = ____)
# Plot Austin precipitation data in the bottom axes
____.plot(____, ____, color = ____)
____.plot(____, ____, color = ____, linestyle = ____)
____.plot(____, ____, color = ____, linestyle = ____)
plt.show()