使用seaborn包关闭关节图上的边缘分布轴

pbr*_*ach 9 python matplotlib seaborn

我喜欢这个特殊的情节以及将函数传递给stat_func关键字以快速绘制和可视化变量之间关系的能力,但有一点.如何"关闭"或不绘制边缘分布轴?

它看起来不错,但有时我不想要这个功能.

例如,使用此代码:

import numpy as np
import seaborn as sns

x = (np.arange(100) + np.random.randn(100)*20
y = (np.arange(100) + np.random.randn(100)*20
sns.jointplot(x, y, kind='reg')
Run Code Online (Sandbox Code Playgroud)

如何删除主轴顶部和右侧的kde子图?

mwa*_*kom 14

您可以JointGrid直接使用:

from scipy import stats

g = sns.JointGrid(x, y, ratio=100)
g.plot_joint(sns.regplot)
g.annotate(stats.pearsonr)
g.ax_marg_x.set_axis_off()
g.ax_marg_y.set_axis_off()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述