0

I attempted to plot a scatterplot and successfully figured out how to annotate each plot point with the team name. However, the annotations overlap and generally don't look very clean. Every example I've found doesnt quite work with my code, could somehow help me out?

fig, ax = plt.subplots(figsize=(15,8))
# plot
ax.scatter(x=df_final['FIP'],y=df_final['OPS+'],c='DarkBlue')
texts = []  

# set labels
ax.set_xlabel('FIP')
ax.set_ylabel('OPS+')

# annotate points in axis
for idx, row in df_final.iterrows():
    ax.annotate(row['Team'], (row['FIP'], row['OPS+']) ) 
# force matplotlib to draw the graph
plt.show()

Output of my scatterplot

  • To adjust the text, you can try the answer here -> https://stackoverflow.com/questions/19073683/how-to-fix-overlapping-annotations-text/34762716#34762716 – Redox Sep 06 '22 at 04:38

0 Answers0