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