Python Forum

Full Version: How to add lables to the scatter plot?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

I created a scatter plot with two numbers (Budget & Revenue)
df.plot(x='budget_adj', y = 'revenue_adj', kind = 'scatter');
And now I want to add the labeling to the points on my scatterplot. The labeling comes from the column 'Original_title'

How can I do this?

Thanks
J
see: http://jonathansoma.com/lede/algorithms-...in-pandas/
but it's always helpful when you post runable code, it lets us test our answers.
It’s example of my code. Cluster - name of column where my labels are. Targets - name of my labels.

targets = ['0','1','2','3','4']
colors = ['red','blue','black','pink','green']
for target, color in zip(targets,colors):
    indicesToKeep = finalDf['Cluster'] == target
    ax.scatter(finalDf.loc[indicesToKeep, 'principal component 1']
               , finalDf.loc[indicesToKeep, 'principal component 2']
               , c = color
               , s = 50)
ax.legend(targets)
ax.grid()
LK91 you are answering a post that is a half-year old.