【问题标题】:Seaborn JointGrid hexplot: aspect ratio issueSeaborn JointGrid hexplot:纵横比问题
【发布时间】:2015-06-22 08:29:16
【问题描述】:

我正在尝试创建一个 JointGrid 图,但在正确设置纵横比方面遇到了一些问题。下面附上相关代码和图。不知道我做错了什么。

fig = plt.figure()
sns.set_style("ticks")
g = sns.JointGrid(X, Y, xlim=[0, max(X)], ylim=[0, max(Y)])
g.plot_marginals(sns.distplot, color=".5")
g.plot_joint(plt.hexbin, bins='log', gridsize=30, cmap=color)

还有输出图:

我不确定我做错了什么;我看着这个:https://github.com/mwaskom/seaborn/issues/271 但那里的修复没有奏效。

谢谢!

【问题讨论】:

  • 你是怎么把颜色条放在那里的?
  • 你可以像这样添加代码:cax = g.fig.add_axes([1, 0.20, .01, 0.5]); cb = plt.colorbar(cax=cax)

标签: python matplotlib plot seaborn


【解决方案1】:

我想通了;在这里发布我的解决方案,以防将来有人遇到同样的问题。

fig = plt.figure()
sns.set_style("ticks")
g = sns.JointGrid(X, Y)
g.plot_marginals(sns.distplot, color=".5")
g.plot_joint(plt.hexbin, bins='log', gridsize=30, cmap=color, extent=[0, np.max(X), 0, np.max(X)])

我基本上只是将它们的范围设置为等于 X 数组的最大值(其最大值高于 Y,从而导致奇怪的纵横比)。

最终结果是这样的:

【讨论】:

    猜你喜欢
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 1970-01-01
    • 2012-07-14
    • 2014-06-13
    相关资源
    最近更新 更多