How to label data points in matplotlib scatter plot while looping through pandas dataframes?
<p>I have a pandas dataframe including the following columns: </p>

<pre><code>label = ('A' , 'D' , 'K', 'L', 'P')
x = (1 , 4 , 9, 6, 4)
y = (2 , 6 , 5, 8, 9)
plot_id = (1 , 1 , 2, 2, 3)
</code></pre>

<p>I want to creat 3 seperate scatter plots - one for each individual <code>plot_id</code>.  So the first scatter plot should consists all entries where <code>plot_id == 1</code> and hence the points (1,2) and (4,6). Each data point should be labelled by <code>label</code>. Hence the first plot should have the labels <code>A</code>and <code>B</code>.</p>

<p>I understand I can use <code>annotate</code> to label, and I am familiar with <code>for</code> loops. But I have no idea how to combine the two.</p>

<p>I wish I could post better code snippet of what I have done so far - but it's just terrible. Here it is:</p>

<pre><code>for i in range(len(df.plot_id)):
    plt.scatter(df.x[i],df.y[i])
    plt.show()
</code></pre>

<p>That's all I got - unfortunately. Any ideas on how to procede?</p>