python 中是否有与 R 的 GGally::ggpairs 函数等效的函数?

abd*_*ha4 4 python plot ggpairs

GGally::ggpairs函数提供对数字和分类数据类型的支持,使得可以通过几行代码在一个地方查看所有变量之间的交互,但具有很高的灵活性。
这是一个例子:

cols = c("#4c86ad", "#f5dfb3")
insurance_data %>%
  dplyr::select(age, bmi, smoker, charges) %>%
  GGally::ggpairs(
    lower = list(
      continuous = GGally::wrap("points", col = cols[1],alpha=0.6),
      combo = GGally::wrap("box", fill = "white", col ="black")
    ),
    upper = list(
      continuous = GGally::wrap("cor", col = cols[1]),
      combo = GGally::wrap("facetdensity", col = "black")
    ),
    diag = list(
      continuous = GGally::wrap("barDiag", fill = cols[2], col ="black", bins = 18),
      discrete = GGally::wrap("barDiag", fill = cols[2], col ="black"))
  )
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有没有办法在 python 中重现这个?

小智 5

我喜欢在 R 中使用 ggpairs,并发现seaborn 的 PairGrid 与之类似。

您可以指定要放置在每个“布局部分”中的布局样式和绘图类型

您可以在文档中查看更多示例,但这里是一个示例。

import seaborn as sns
penguins = sns.load_dataset("penguins")
g = sns.PairGrid(penguins, hue="species")
g.map_diag(sns.histplot)
g.map_offdiag(sns.scatterplot)
g.add_legend()
Run Code Online (Sandbox Code Playgroud)

带有企鹅数据的 Seaborn PairGrid 示例