Seaborn JointGrid KDE 边缘图上的重新缩放轴

Tim*_*Tim 2 python matplotlib seaborn

我正在尝试创建一个 seaborn JointGrid 对象,在joint_plot和边缘的KDEs中使用散布+轮廓。这让我非常接近,但 y 轴边际没有适当缩放。手动重新缩放边缘轴的最佳方法是什么?提前致谢!

f = p.figure()
ax = f.add_subplot(111)
g = sns.JointGrid(xdata, ydata, xlim=(0,1), ylim=(0,1))
g.plot_joint(sns.kdeplot, shade=True, cmap="Greys", n_levels=10)
g.plot_joint(p.scatter, color='#e74c3c', s=1.5)
g.plot_marginals(sns.kdeplot, color="black", shade=True)
g.ax_joint.collections[0].set_alpha(0)
g.set_axis_labels(r'$\frac{\chi_{0}^2-\chi_{\mathrm{null},1}^2{\chi_{0}^2}$', r'$\frac{\chi_{0}^2-\chi_{\mathrm{null},4}^2}{\chi_{0}^2}$')
p.gcf().subplots_adjust(bottom=.15)
p.gcf().subplots_adjust(left=.15)
p.savefig('something')
Run Code Online (Sandbox Code Playgroud)

这是一个新帐户,我没有发布图片的声誉 - 我尝试的链接在这里 -> http://i.imgur.com/9iG860U.png

在此处输入图片说明

tmd*_*son 6

您可以通过使用 访问 y 边际轴来控制它g.ax_marg_y。从那里,您可以以通常的matplotlib方式控制轴限制。在这种情况下,您要调整xlim

g.ax_marg_y.set_xlim(0,xmax)
Run Code Online (Sandbox Code Playgroud)

xmax您需要手动更改的号码在哪里。

如果需要,您可以xmax使用get_xlim()以下命令找到当前:

xmin, xmax = g.ax_marg_y.get_xlim()
Run Code Online (Sandbox Code Playgroud)

然后你可以增加xmax一些倍数。例如:

xmin, xmax = g.ax_marg_y.get_xlim()
g.ax_marg_y.set_xlim(xmin,xmax*2)
Run Code Online (Sandbox Code Playgroud)