在seaborn jointplot中获得传奇

Vin*_*ent 11 python seaborn

我有兴趣使用seaborn关节图来可视化两个numpy阵列之间的相关性.我喜欢kind ='hex'参数给出的视觉区别,但我也想知道不同阴影对应的实际计数.有谁知道如何把这个传说放在一边甚至是情节?我试着查看文档但找不到它.

谢谢!

cry*_*ick 12

编辑:更新以使用新的Seaborn ver.

您需要通过创建一个新轴手动完成add_axes,然后将ax的名称传递给plt.colorbar().

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

x = np.random.normal(0.0, 1.0, 1000)
y = np.random.normal(0.0, 1.0, 1000)
hexplot = sns.jointplot(x, y, kind="hex")
plt.subplots_adjust(left=0.2, right=0.8, top=0.8, bottom=0.2)  # shrink fig so cbar is visible
# make new ax object for the cbar
cbar_ax = hexplot.fig.add_axes([.85, .25, .05, .4])  # x, y, width, height
plt.colorbar(cax=cbar_ax)
plt.show()
Run Code Online (Sandbox Code Playgroud)

Seaborn hexplot与colorbar

来源:我几乎放弃了后,我读了dev的说

"工作/效益比[实施彩条]太高了"

但后来我终于找到这个解决方案中的另一个问题.