How to add lables to the scatter plot? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: How to add lables to the scatter plot? (/thread-10858.html) |
How to add lables to the scatter plot? - Jack_Sparrow - Jun-10-2018 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 RE: How to add lables to the scatter plot? - Larz60+ - Jun-10-2018 see: http://jonathansoma.com/lede/algorithms-2017/classes/fuzziness-matplotlib/understand-df-plot-in-pandas/ but it's always helpful when you post runable code, it lets us test our answers. RE: How to add lables to the scatter plot? - LK91 - Dec-11-2019 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() RE: How to add lables to the scatter plot? - Larz60+ - Dec-11-2019 LK91 you are answering a post that is a half-year old. |