축 레이블 사용자 지정과 제목 추가
축 레이블을 사용자 지정하려면 Axes 객체의 set_xlabel과 set_ylabel 메서드를 사용합니다. 제목을 추가하려면 set_title 메서드를 사용해요.
이 연습 문제에서는 축 레이블의 내용을 직접 지정하고, 플롯에 제목을 추가해 보겠습니다.
이전과 마찬가지로 데이터는 메모리에 로드된 pandas DataFrame 객체 seattle_weather와 austin_weather로 제공됩니다. 각각 "MONTH" 열과 "MLY-PRCP-NORMAL" 열을 가지고 있어요. 제공된 샘플 코드의 첫 두 줄에서 이 데이터들이 서로에 대해 플로팅되어 있습니다.
또한, fig라는 Figure 객체와 ax라는 Axes 객체가 이미 생성되어 있어요.
이 연습은 강의의 일부입니다
Matplotlib으로 시작하는 데이터 시각화
연습 안내
set_xlabel메서드를 사용해 레이블"Time (months)"을(를) 추가하세요.set_ylabel메서드를 사용해 레이블"Precipitation (inches)"을(를) 추가하세요.set_title메서드를 사용해 제목"Weather patterns in Austin and Seattle"을(를) 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-PRCP-NORMAL"])
ax.plot(austin_weather["MONTH"], austin_weather["MLY-PRCP-NORMAL"])
# Customize the x-axis label
____
# Customize the y-axis label
____
# Add the title
____
# Display the figure
plt.show()