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?
#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


Messages In This Thread
RE: How to add lables to the scatter plot? - by LK91 - Dec-11-2019, 08:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,306 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  Matplotlib scatter plot slider with datetime sonny 0 2,986 Feb-05-2021, 02:31 AM
Last Post: sonny
  matplotlib creating a scatter plot via PathCollection tpourjalali 0 2,512 Apr-11-2020, 05:59 PM
Last Post: tpourjalali
  How to create correct scatter plot for PCA? LK91 0 2,142 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,531 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