hexbin 联合图的 Seaborn 成对矩阵 [英] Seaborn pairwise matrix of hexbin jointplots
本文介绍了hexbin 联合图的 Seaborn 成对矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试生成一个比较分布的成对图矩阵(类似这样的事情).由于我有很多点,我想使用 hexbin 图来减少时间和绘图复杂性.
I am trying to produce a matrix of pairwise plots comparing distributions (something like this). Since I have many points I want to use a hexbin plot to reduce time and plot complexity.
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()
尽管如此,与其创建图表矩阵,不如在各个窗口中独立创建多个图表.
Nevertheless, instead of creating the matrix of plots it creates several plots independently in various windows.
我也想过使用 seaborn.pairplot
来生成这个,但我无法将 "hex"
作为值传递给 kind
.
I also thought of using seaborn.pairplot
to produce this but I can not pass "hex"
as a value to kind
.
推荐答案
See the last example in the tutorial on using custom functions with FacetGrid
, which I'll reproduce here:
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])
这篇关于hexbin 联合图的 Seaborn 成对矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文