python - 六边形联合图的 Seaborn 成对矩阵

标签 python matplotlib plot seaborn

我正在尝试生成比较分布 (something like this) 的成对图矩阵。由于我有很多要点,所以我想使用 hexbin 图来减少时间和绘图的复杂性。

import seaborn as sns
import matplotlib.pyplot as plt


tips = sns.load_dataset("tips")

g = sns.FacetGrid(tips, col="time", row="sex")
g.map(sns.jointplot, "total_bill", "tip", kind="hex")
plt.show()

然而,它不是创建绘图矩阵,而是在不同窗口中独立创建多个绘图。

我也想过使用 seaborn.pairplot 来生成这个,但我不能将 "hex" 作为值传递给 kind

最佳答案

请参阅 tutorial on using custom functions 中的最后一个示例使用 FacetGrid,我将在此处重现:

def hexbin(x, y, color, **kwargs):
    cmap = sns.light_palette(color, as_cmap=True)
    plt.hexbin(x, y, gridsize=15, cmap=cmap, **kwargs)

g = sns.FacetGrid(tips, hue="time", col="time", size=4)
g.map(hexbin, "total_bill", "tip", extent=[0, 50, 0, 10])

enter image description here

关于python - 六边形联合图的 Seaborn 成对矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31385375/

相关文章:

python - 没有名为 'azure.storage.blob.sharedaccesssignature' 的模块

python - pandas - 使用 'melt' 函数 reshape 表格

Python Win32 向 Chrome 发送击键

python-2.7 - 如何在python中保存直方图?

python - 基于列而不是行索引/索引的 Bokeh 链接/刷光

python - Golang 中 UUID4 的整数表示

python - 在 python 图中, "1e8"相对于 y 轴意味着什么?

python - 类型错误 : unsupported operand type(s) for +: 'float' and 'datetime.timedelta'

python - 真的只有 4 个 Matplotlib 线型吗?

plot - 如何在 gnuplot 中使标签和标题加粗?