如何将 seaborn pairplot 绘制为子图?

How to plot seaborn pairplot as subplot?

我使用以下内容创建我的子图

fig, axs = plt.subplots(2,2)
sns.plotfunc(..., ax = axs[0])

但是,seaborn 中的 pairplot 函数不支持 ax augment,知道如何将其绘制为子图吗?

提前致谢。

实际上,如果我传递plt.subplots(2, 2),它将是return 2*2 数组,因此我应该使用sns.plotfunc(..., ax = axs[0][1]),而不是

您可以使用 Seaborn 的 PairGrid 绘制多个配对图,如下所示:

g = sns.PairGrid(df, y_vars=['variable_a','variable_b'], x_vars=["variable_c", "variable_d"], height=4)
g.map(sns.regplot)
plt.show()

可以找到有关如何使用 PairGrid 的另一个示例 here