【发布时间】:2019-03-21 15:54:21
【问题描述】:
我想为每个变量分别着色我的边缘图。
d1 = np.random.normal(10,1,100)
d2 = np.random.gamma(1,2,100)
col1 = sns.color_palette()[0]
col2 = sns.color_palette()[1]
col3 = sns.color_palette()[2]
jp = sns.jointplot(d1, d2, kind="hex", annot_kws=dict(stat="r"), joint_kws=dict(bins='log'))
ax = jp.ax_joint
ax.plot(ax.get_xlim(), ax.get_ylim(), ls="--", c=".3", label="1:1")
我想分别为每个边缘图着色。但是,当我将参数分配给边缘轴时,它们会用相同的参数为两个边缘图着色。
jp = sns.jointplot(d1, d2, kind="hex", annot_kws=dict(stat="r"), joint_kws=dict(bins='log'), marginal_kws=dict(hist_kws= {'color': col2}))
ax = jp.ax_joint
ax.plot(ax.get_xlim(), ax.get_ylim(), ls="--", c=".3", label="1:1")
我可以为“facecolors”着色,但不能为轴本身着色。非常感谢任何帮助!
jp = sns.jointplot(d1, d2, kind="hex", annot_kws=dict(stat="r"), joint_kws=dict(bins='log'), marginal_kws=dict(hist_kws= {'color': col2}))
ax = jp.ax_joint
ax.plot(ax.get_xlim(), ax.get_ylim(), ls="--", c=".3", label="1:1")
# new code
jp.ax_marg_x.set_facecolor(col1)
jp.ax_marg_y.set_facecolor(col3)
【问题讨论】:
标签: python python-3.x matplotlib seaborn