【问题标题】:Rescale axis on Seaborn JointGrid KDE marginal plotsSeaborn JointGrid KDE 边缘图上的重新缩放轴
【发布时间】:2016-03-24 01:51:13
【问题描述】:

我正在尝试创建一个 seaborn JointGrid 对象,该对象在joint_plot 中具有散点图+轮廓,在边际中具有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')

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

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

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

    g.ax_marg_y.set_xlim(0,xmax)
    

    其中xmax 是您需要手动更改的号码。

    如果需要,可以使用get_xlim()找到当前的xmax:

    xmin, xmax = g.ax_marg_y.get_xlim()
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 2015-01-17
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      • 2016-08-04
      • 1970-01-01
      相关资源
      最近更新 更多