python - 如何更改 seaborn 联合图中的十六进制大小? (六边形本身,而不是垃圾箱)

标签 python python-2.7 pandas seaborn

在 Seaborn 中使用六边形联合图生成一些“热图”,显示篮球运动员在球场上投篮次数最多的位置。数据来自 pandas dataframe,其中 LocX 代表球员在球场上的水平位置(-250 和 250 是边线,0 是与篮筐对齐),LocY 是距离篮筐的纵向距离。我使用相同的代码为多个玩家生成 map ,但六边形的大小在玩家之间变化很大(即使两个玩家的总射门数相似)。这是我想要的结果Good Plot ,

enter image description here

但这里有一个根本不起作用Bad Plot .

enter image description here

这是我生成它的代码:

cmap=plt.cm.gist_heat_r
joint_shot_chart = sns.jointplot(shot_df.LocX, shot_df.LocY, stat_func=None, kind='hex', space=0, color=cmap(.2), cmap=cmap)

是否有可用于更改六边形大小的 kwarg?

最佳答案

您可以解析 gridsize 参数。较高的值会导致较小的 hexbin。

import numpy as np, pandas as pd; np.random.seed(0)
import seaborn as sns; sns.set(style="white", color_codes=True)

tips = sns.load_dataset("tips")
joint_kws=dict(gridsize=5)
g = sns.jointplot(x="total_bill", y="tip", data=tips,kind="hex", joint_kws= joint_kws)

关于python - 如何更改 seaborn 联合图中的十六进制大小? (六边形本身,而不是垃圾箱),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40923019/

相关文章:

python - 如何在不重新安装模块的情况下更新 mac python

python - 将维基百科表格抓取到 Pandas 数据框

python - Pandas :FutureWarning:改为使用 pd.to_datetime

python - 使用列表 Python 创建矩阵

python >=3.5 : Checking type annotation at runtime

python - Python 中的编码风格

Python Selenium,逐个字母发送键

python - Pandas 数据框中的新列基于现有列中变量的值

python - scrapy 被 redis 阻塞

python - 带有语句解释的好 Python