Seaborn jointplot show annotation

2019-08-16 07:57发布

问题:

I have plotted a jointplot of two variables. I have passed values to the annot_kws argument but nothing is showing in my plot.

import numpy as np
import seaborn as sns

d1 = np.random.normal(10,1,100)
d2 = np.random.gamma(1,2,100)
col1 = sns.color_palette()[0]
col2 = sns.color_palette()[1]
col3 = sns.color_palette()[2]

def hexbin_jointplot_sns(d1, d2, col1, col2, bins='log'):
    """ """
    jp = sns.jointplot(d1, d2, kind="hex", annot_kws=dict(stat="r"), joint_kws=dict(bins=bins))

    # plot the 1:1 line
    ax = jp.ax_joint
    ax.plot(ax.get_xlim(), ax.get_ylim(), ls="--", c=".3", label="1:1")

    # color the marginal distributions separately
    for patch in jp.ax_marg_x.patches:
        patch.set_facecolor(col1)

    for patch in jp.ax_marg_y.patches:
        patch.set_facecolor(col2)

    return jp

hexbin_jointplot_sns(d1, d2, col1, col2, bins='log')

How do I show the annotation in my plot?