Python Forum
How to add lables to the scatter plot?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add lables to the scatter plot?
#1
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
Reply
#2
see: http://jonathansoma.com/lede/algorithms-...in-pandas/
but it's always helpful when you post runable code, it lets us test our answers.
Reply
#3
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()
Reply
#4
LK91 you are answering a post that is a half-year old.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,234 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  Matplotlib scatter plot slider with datetime sonny 0 2,918 Feb-05-2021, 02:31 AM
Last Post: sonny
  matplotlib creating a scatter plot via PathCollection tpourjalali 0 2,429 Apr-11-2020, 05:59 PM
Last Post: tpourjalali
  How to create correct scatter plot for PCA? LK91 0 2,069 Dec-11-2019, 07:53 PM
Last Post: LK91
  It doesn't show scatter plot but it says: "<Figure size 640x480 with 1 Axes>" dcardonaa 0 3,457 Oct-10-2019, 02:34 AM
Last Post: dcardonaa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020