在 Bivariate seaborn histplot 块中的每个单元格之间添加线条

Add lines between each cell in a Bivariate seaborn histplot blocks

我一直在尝试在 sns.histplot 中的每个单元格之间添加行,其中两个变量与 sns.heatmap 相同,但我每次都失败了。

我已经尝试使用 linewidths 参数,因为这是使用热图进行此操作的方式

penguins = sns.load_dataset("penguins")
sns.histplot(penguins, x="bill_depth_mm", y="body_mass_g", linewidths=1)

但没有任何变化。我知道我可以先聚合数据,然后使用热图,但我觉得自己太笨了,我只能用一种方法来做。我正在使用 seaborn 0.11.2

提前致谢!

penguins = sns.load_dataset("penguins")
sns.histplot(
    penguins, x="bill_depth_mm", y="body_mass_g", linewidths=1,
    edgecolor="w"  # <-- Here's what you're missing
)