我想要在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