
from Scratch
55
그림 3-6
3.4
산점도
산점도(
scatterplot
)는 두 변수 간의 연관 관계를 보여 주고 싶을 때 적합한 그래
프다. 예를 들어 그림
3
-
7
은 각 사용자의 친구 수와 그들이 매일 사이트에서 체
류하는 시간 사이의 연관성을 보여 준다.
friends = [ 70, 65, 72, 63, 71, 64, 60, 64, 67]
minutes = [175, 170, 205, 120, 220, 130, 105, 145, 190]
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
plt.scatter(friends, minutes)
#
각
포인트에
레이블을
달자
.
for label, friend
_
count, minute
_
count in zip(labels, friends, minutes):
plt.annotate(label,
xy=(friend
_
count, minute
_
count), #
레이블을
데이터
포인트
근처에
두되
xytext=(5, -5), #
약간
떨어져
있게
하자
.
textcoords='offset points')
plt.title("Daily Minutes vs. Number of Friends")
plt.xlabel("# of friends") ...