ejshin1
ejshin1

Reputation: 1167

Scatter plot label overlaps - matplotlib

I would like to draw a scatter plot with labeling. However, these labels are overlapping. How can I enhance its look so that I can see numbers better? Also, I have numbers in integer, but it shows label values in float. I am wondering why.

Looking forward to hearing back from you guys.

Here's my code:

col = df['type'].map({'a':'r', 'b':'b', 'c':'y'})
ax = df.plot.scatter(x='x', y='y', c=col)

df[['x','y','id']].apply(lambda x: ax.text(*x),axis=1)

enter image description here

Upvotes: 9

Views: 13462

Answers (1)

ZahraRezaei
ZahraRezaei

Reputation: 261

I suggest that you install the adjustText package:

python -m pip install adjustText

and later follow this old Stackoverflow answer.

Upvotes: 3

Related Questions