【发布时间】:2016-11-24 21:37:44
【问题描述】:
我正在尝试在 Seaborn Grid 中获取 hexbin 图。我有以下代码,
# 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)
如何修复十六进制图,使其覆盖图形的整个表面,而不仅仅是显示的绘图区域的子集?
【问题讨论】:
-
请解释我如何提高问题的质量,而不是投反对票。我很乐意这样做。
-
这可能是因为你没有一个最小的工作示例。
-
更新了代码,谢谢!
标签: python matplotlib seaborn