六边形联合图的 Seaborn 成对矩阵
Seaborn pairwise matrix of hexbin jointplots
我正在尝试生成比较分布的成对图矩阵 (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()
然而,它没有创建地块矩阵,而是在各种 windows 中独立地创建了几个地块。
我也想过使用 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])
我正在尝试生成比较分布的成对图矩阵 (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()
然而,它没有创建地块矩阵,而是在各种 windows 中独立地创建了几个地块。
我也想过使用 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])