
# A scatterplot is the right choice for visualizing the **relationship** 
# between two paired sets of data. 

# Data on the relationship between the number of friends users have and 
# the number of minutes they spend on the site every day:

friends = [ 70, 65, 72, 63, 71, 64, 60, 64, 67]
minutes = [175, 170, 205, 120, 220, 130, 105, 145, 190]

# Artificial labels to mark the point on the scatter plot
labels  = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']

from matplotlib import pyplot as plt

plt.scatter(friends, minutes)		# This creates the scatter plot

# Annotate a point: (we annotate the first data point in this call)

plt.annotate(labels[0],				# Annotate with this label
             xy=(friends[0], minutes[0]), 	# at this point location
	     xytext=(5, -5), 			# use this offset from point loc
	     textcoords='offset points')	# indicate "use offset"

# You will need to do this for every point...
# Therefore, we use a for-loop:

for label, friend_count, minute_count in zip(labels, friends, minutes):
    plt.annotate(label,
                 xy=(friend_count, minute_count), # put the label with its point
                 xytext=(5, -5),                  # but slightly offset
                 textcoords='offset points')

# Now add titles and lables

plt.title("Daily Minutes vs. Number of Friends")
plt.xlabel("# of friends")
plt.ylabel("daily minutes spent on the site")

plt.show()
