
Data Science
54
plt.axis([2016.5, 2018.5, 0, 550])
plt.title("Not So Huge Anymore")
plt.show()
그림 3-5
3.3
선 그래프
앞에서 이미 살펴본 바와 같이
plt.plot()
을 이용하면 선 그래프(
line
chart
)를
그릴 수 있다. 이 그래프는 그림
3
-
6
과 같이 어떤 경향을 보여 줄 때 유용하다.
variance = [1, 2, 4, 8, 16, 32, 64, 128, 256]
bias
_
squared = [256, 128, 64, 32, 16, 8, 4, 2, 1]
total
_
error = [x + y for x, y in zip(variance, bias
_
squared)]
xs = [i for i,
_
in enumerate(variance)]
#
한
차트에
여러
개의
선을
그리기
위해
# plt.plot
을
여러
번
호출할
수
있다
.
plt.plot(xs, variance, 'g-', label='variance') #
실선
plt.plot(xs, bias
_
squared, 'r-.', label='bias^2') #
일점쇄선
plt.plot(xs, total
_
error, 'b:', label='total error') #
점선
#