【问题标题】:Is there a way to tie axis of different axes after they are created in matplotlib?有没有办法在 matplotlib 中创建不同轴的轴后绑定它们?
【发布时间】:2015-07-19 23:09:19
【问题描述】:

一个人做得到

fig, ax = subplots(nrows=2, ncols=2, sharex=True, sharey=True)

使轴共享轴。

我想以更复杂的方式将不同子图的不同轴联系在一起,例如,ax1 的 x 轴到 ax2,但 ax2 的 y 轴到 ax3 等等。

我认为一种方法是调用subplot 并使用sharex/sharey 关键字,但这是在创建时完成的。 在创建轴后,在 matplotlib 中是否有面向对象的方式来执行此操作?

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    我认为现在有办法做到这一点。

    见:
    - How share x axis of two subplots after they are created?
    - matplotlib set shared axis

    所以我认为你的例子应该是这样的:

    ax1.get_shared_x_axes().join(ax1, ax2)
    ax2.get_shared_y_axes().join(ax2, ax3)
    

    【讨论】:

      猜你喜欢
      • 2018-03-17
      • 2021-10-30
      • 2011-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多