gpt4 book ai didi

python - 使 seaborn.PairGrid() 看起来像 pairplot()

转载 作者:行者123 更新时间:2023-12-05 08:49:43 24 4
gpt4 key购买 nike

在下面的示例中,我如何使用 seaborn.PairGrid() 重现由 seaborn.pairplot() 创建的绘图?具体来说,我希望对角线分布跨越垂直轴。带有白色边框等的标记……也很棒。谢谢!

import seaborn as sns
import matplotlib.pyplot as plt

iris = sns.load_dataset('iris')

# pairplot() example
g = sns.pairplot(iris, kind='scatter', diag_kind='kde')
plt.show()

# PairGrid() example
g = sns.PairGrid(iris)
g.map_diag(sns.kdeplot)
g.map_offdiag(plt.scatter)
plt.show()

enter image description here enter image description here

最佳答案

这是 quite simple实现。您的情节与 pairplot 所做的主要区别是:

  • 使用PairGriddiag_sharey参数
  • 使用 sns.scatterplot 代替 plt.scatter

有了这个,我们有:

iris = sns.load_dataset('iris')
g = sns.PairGrid(iris, diag_sharey=False)
g.map_diag(sns.kdeplot)
g.map_offdiag(sns.scatterplot)

enter image description here

关于python - 使 seaborn.PairGrid() 看起来像 pairplot(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63439522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com