我对使用seaborn联合图来可视化两个numpy数组之间的相关性很感兴趣。我喜欢kind='hex‘参数提供的视觉区别,但我也想知道不同阴影对应的实际计数。有谁知道如何把这个传奇放在一边,甚至放在情节上?我试着查看文档,但找不到它。
谢谢!
发布于 2015-04-28 10:03:00
编辑:已更新以使用新的Seaborn版本。
您需要使用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()

资料来源:我几乎放弃后,我read a dev say的
“实现colorbars的工作量/收益比率太高”
但后来我最终找到了这个解决方案in another issue。
发布于 2021-04-28 01:20:37
下面的方法对我很有效:
t1 = sns.jointplot(data=df, x="originalestimate_hours", y="working_hours_per_day_created_target", hue="status")
t1.ax_joint.legend_._visible=False
t1.fig.legend(bbox_to_anchor=(1, 1), loc=2)https://stackoverflow.com/questions/29096632
复制相似问题