seaborn散点图中的工具提示

时间:2018-04-08 07:57:25

标签: python matplotlib seaborn

我这里有一个测试数据框。

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']})

这将看起来像

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

现在,我想要使用seaborn列进行z散点图并提供工具提示。这是我的seaborn散点图代码

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')

这是图。 enter image description here

现在,当我将鼠标悬停在数据点上时,我希望为该行显示列z的值。我该怎么做?

0 个答案:

没有答案