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

Python Seaborn JointGrid KDE边缘图上的轴重缩放,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我试图创建一个seaborn JointGrid对象,在joint_图中使用散射+轮廓,在边缘使用KDE。这让我非常接近,但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_level

我试图创建一个seaborn JointGrid对象,在joint_图中使用散射+轮廓,在边缘使用KDE。这让我非常接近,但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')
这是一个新帐户,我没有发布图片的声誉-我尝试的链接在这里->


您可以通过使用
g.ax\u marg\u y
访问y边缘轴来控制此操作。从那里,您可以以通常的
matplotlib
方式控制轴限制。在这种情况下,您需要调整
xlim

g.ax_marg_y.set_xlim(0,xmax)
xmin, xmax = g.ax_marg_y.get_xlim()
其中
xmax
是您需要手动更改的数字

如果需要,可以使用
get\u xlim()
查找当前的
xmax

然后您可以将
xmax
增加几倍。例如:

xmin, xmax = g.ax_marg_y.get_xlim()
g.ax_marg_y.set_xlim(xmin,xmax*2)

您可以通过使用
g.ax\u marg\u y
访问y边缘轴来控制此操作。从那里,您可以以通常的
matplotlib
方式控制轴限制。在这种情况下,您需要调整
xlim

g.ax_marg_y.set_xlim(0,xmax)
xmin, xmax = g.ax_marg_y.get_xlim()
其中
xmax
是您需要手动更改的数字

如果需要,可以使用
get\u xlim()
查找当前的
xmax

然后您可以将
xmax
增加几倍。例如:

xmin, xmax = g.ax_marg_y.get_xlim()
g.ax_marg_y.set_xlim(xmin,xmax*2)