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

标签 python seaborn facet-grid

在下面的示例中,我如何使用 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/

相关文章:

python - 如何在sqlite3中同时搜索多个表?

python - 在转换为列表时,如何防止 Python 将两位数整数拆分为两个整数

r - `ggplot2 - facet_grid` : Axes without ticks in interior facets

r - 如何在 ggplot facets 中按值对数据进行排序

python - 正常随边界变化?

python - 使用 python-docx 检索具有文档结构的文档内容

python - seaborn 是否计算预测(不是置信度)带?

python - 使用辅助轴线图制作分类或分组条形图

python - 如何为 Dataframe 中的所有列绘制 Seaborn Distplots 矩阵

python - FacetGrid 的 Matplotlib 轴