7

I have a test data frame here.

import pandas as pd
import numpy as np
import seaborn as sns
df = pd.DataFrame({'x': [1,2,3,4],
                   'y': [1,4,9,16],
            'z' : ['A','B','C','D']})

This will look as

   x   y  z
0  1   1  A
1  2   4  B
2  3   9  C
3  4  16  D

Now I want to do a seaborn scatter plot and put tool tips using the z column. Here is my seaborn scatter plot code

g = sns.regplot(x=df["x"],
                y=df["y"], 
            fit_reg=False, scatter_kws={'s':30},
            color='red')

g.set_title('My Plot')

fig = g.get_figure()

fig.savefig('myplot.png')

And here is the figure. enter image description here

Now when I hover over the data point, I want the value of column z to be displayed for that row. How would I do that ?

user9026
  • 852
  • 2
  • 9
  • 20
  • Can this be done in base `matplotlib` without using `seaborn` ? – user9026 Apr 08 '18 at 08:41
  • 2
    Why was this marked as a duplicate? The referenced answers refer only to matplotlib, this question here is about seaborn. – Toby Dec 12 '19 at 05:57

0 Answers0