【发布时间】:2020-02-27 17:19:12
【问题描述】:
是否可以向 JointGrid 的直方图添加百分比?
我可以忍受低于、高于或高于栏的百分比。 或者用一个额外的轴显示百分比+线。 我浏览了 JointGrid 的源代码,以找到一种方法来恢复两个直方图的隐藏轴,这样我就可以向它们添加百分比。
我还为直方图轴尝试了不同的标签,但这不起作用,因为它们是共享的:
hex.ax_marg_y.set_yticklabels(["test", "label"])
这是我正在进行的工作:
labels = ['Ma 13', 'Di 14', 'Wo 15', 'Do 16', 'Vr 17', 'Za 18', 'Zo 19', 'Ma 20']
hex = sns.JointGrid(x, y, height = 12)
hex.ax_marg_x.hist(x, bins=np.arange(-0.5, 23.5))
hex.ax_marg_y.hist(y, bins=np.arange(-0.5, len(labels) + 0.5), orientation="horizontal")
hex.plot_joint(sns.kdeplot, shade=True, cmap="Blues", bw=.11)
plt.ylim(-0.5, len(labels)-0.5)
plt.xlim(-0.5, 23.5)
hex.ax_joint.set_xticks(range(24))
hex.ax_joint.set_yticks(range(len(labels)))
hex.ax_joint.set_yticklabels(labels)
plt.subplots_adjust(left=0.05, right=0.95, top=0.93, bottom=0) # Shrink figure so the legende is visible
hex.x = x2
hex.y = y2
hex.plot_joint(plt.scatter, marker = 'x', c = 'r', s = 190)
plt.show()
【问题讨论】:
标签: python python-3.x matplotlib seaborn