在 Seaborn JointGrid 中将 yticks 添加到边缘

Add yticks to marginals in Seaborn JointGrid

JointGrid or JointPlot 的文档中似乎没有任何示例在边缘图中显示 yticks。如何将 yticks 添加到下面 seaborn JointGrid 图中的边缘图?

import matplotlib.pyplot as plt
import seaborn as sns

tips = sns.load_dataset('tips')
g = sns.JointGrid(x='total_bill', y='tip', data=tips)
g = g.plot_joint(plt.scatter, color='#334f6d')
g = g.plot_marginals(sns.distplot, color='#418470')

我知道来自 g.ax_marg_x.get_yticks() 的 yticks 是什么,但是用

设置它们
g.ax_marg_x.set_yticks(g.ax_marg_x.get_yticks())

似乎没有做任何事情,也没有像 g.ax_marg_x.yaxis.set_visible(True).

这样的其他简单尝试

这绘制了一些东西,但我不确定如何解释这些结果(或者它们是如何计算的;正确的看起来不像密度)。

    import matplotlib.pyplot as plt
    import seaborn as sns

    tips = sns.load_dataset('tips')

    g = sns.JointGrid(x='total_bill', y='tip', data=tips)
    g = g.plot_joint(plt.scatter, color='#334f6d')
    g = g.plot_marginals(sns.distplot, color='#418470', )

    plt.setp(g.ax_marg_x.get_yticklabels(), visible=True)
    plt.setp(g.ax_marg_y.get_xticklabels(), visible=True)

    plt.show()

逆向工程的相关部分在 seaborn 的资源中 @ seaborn/axisgrid.py (link):

# LINE 1623 #
# Set up the subplot grid
f = plt.figure(figsize=(size, size))
gs = plt.GridSpec(ratio + 1, ratio + 1)

ax_joint = f.add_subplot(gs[1:, :-1])
ax_marg_x = f.add_subplot(gs[0, :-1], sharex=ax_joint)
ax_marg_y = f.add_subplot(gs[1:, -1], sharey=ax_joint)

self.fig = f
self.ax_joint = ax_joint
self.ax_marg_x = ax_marg_x
self.ax_marg_y = ax_marg_y

# Turn off tick visibility for the measure axis on the marginal plots
plt.setp(ax_marg_x.get_xticklabels(), visible=False)
plt.setp(ax_marg_y.get_yticklabels(), visible=False)

# Turn off the ticks on the density axis for the marginal plots
plt.setp(ax_marg_x.yaxis.get_majorticklines(), visible=False)
plt.setp(ax_marg_x.yaxis.get_minorticklines(), visible=False)
plt.setp(ax_marg_y.xaxis.get_majorticklines(), visible=False)
plt.setp(ax_marg_y.xaxis.get_minorticklines(), visible=False)
plt.setp(ax_marg_x.get_yticklabels(), visible=False)
plt.setp(ax_marg_y.get_xticklabels(), visible=False)
ax_marg_x.yaxis.grid(False)
ax_marg_y.xaxis.grid(False)