如何更改seaborn jointplot中的十六进制大小? (咒语本身,而不是垃圾箱)

时间:2016-12-02 00:54:42

标签: python python-2.7 pandas seaborn

在Seaborn使用六角形的关节图来制作一些“热图”,显示球场上篮球运动员投篮次数最多的地方。数据来自熊猫数据框,其中LocX代表球员在球场上的水平位置(-250和250是边线,0与篮筐一致),而LocY是距篮筐的长度距离。我使用相同的代码为多个玩家制作地图,但六边形的大小在玩家之间变化很大(即使两个玩家的总镜头数相似)。这是我想要的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来改变六边形的大小吗?

1 个答案:

答案 0 :(得分:3)

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

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)