[Python] 그래프 축(axis)에 단위 표현하기
Python의 matplotlib을 이용해서 graph를 그릴 때, x축과 y축에 단위를 넣고 싶을 때가 있다. 이럴 때는 axis의 Formatting을 해 줌으로써 표현할 수 있다. 코드는 다음과 같다. import matplotlib.pyplot as plt import matplotlib.ticker as mticker #테스트 데이터 x = [i * 55 for i in range(1, 11)] y = [0.219, 0.402, 0.543, 0.646,0.765, 0.880,1.169, 1.358,1.492,1.611] #단위 생성 plt.gca().xaxis.set_major_formatter(mticker.FormatStrFormatter('%.1f s')) plt.gca().yaxis.se..