【问题标题】:Turn off marginal distribution axes on jointplot using seaborn package使用 seaborn 包关闭联合图上的边际分布轴
【发布时间】:2015-01-19 19:21:16
【问题描述】:

我喜欢这个特殊的绘图以及将函数传递给 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')

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

【问题讨论】:

  • 嗯,那不就是一个简单的散点图吗?
  • 在这种情况下,它将具有回归线和指定置信区间以及 Pearson 相关系数和 p 值的范围。
  • 不就是sns.regplot吗?
  • 是减去相关系数。我的意思是我可以自己做,但我只是想知道这是否可以简单地使用该函数来完成。

标签: python matplotlib seaborn


【解决方案1】:

你可以直接使用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()

【讨论】:

    猜你喜欢
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多