-1

I have a simple line plot on Seaborn -

ax = sns.lineplot(data=df2, x="screen", y="bmi")

And I want to know how to label the coordinates of certain points like https://i.stack.imgur.com/Imlzg.jpg. I have tried a few methods but they have not worked. Thanks a lot for helping.

Similar questions asked wanted a way to label a third variable on their graph, but I just want to label the y-values at certain points. No other questions solved this problem.

CSM
  • 1
  • 2

1 Answers1

1

You can simply iterate over the (screen, bmi) tuples and add annotations as follows:

ax = sns.lineplot(data=df2, x='screen', y='bmi')
for screen, bmi in zip(df2['screen'], df2['bmi']):
    ax.annotate(f'({screen}, {bmi})', xy=(screen, bmi))
Michael Hodel
  • 2,845
  • 1
  • 5
  • 10