我想要在Seaborn网格中获取hexbin图。我有以下代码,PairGrid中的Hexbin图与Seaborn
# Works in Jupyter with Python 2 Kernel.
%matplotlib inline
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
# Borrowed from http://stackoverflow.com/a/31385996/4099925
def hexbin(x, y, color, **kwargs):
cmap = sns.light_palette(color, as_cmap=True)
plt.hexbin(x, y, gridsize=15, cmap=cmap, extent=[min(x), max(x), min(y), max(y)], **kwargs)
g = sns.PairGrid(tips, hue='sex')
g.map_diag(plt.hist)
g.map_lower(sns.stripplot, jitter=True, alpha=0.5)
g.map_upper(hexbin)
我怎样才能解决hexbin地块以这样一种方式,他们覆盖图的整个表面,而不是只是所示绘图区域的一个子集?
而是反对投票的请解释我如何能提高问题的质量。我很乐意这样做。 – Stereo
这可能是因为你没有一个最小的工作例子。 – GWW
更新了代码,谢谢! – Stereo