【问题标题】:Don't automatically adjust xlim, ylim for certain plot items in matplotlib不要为 matplotlib 中的某些绘图项自动调整 xlim、ylim
【发布时间】:2013-04-27 05:58:57
【问题描述】:

当使用 matplotlib 绘制一堆线时,坐标轴范围会自动调整以使所有绘图都适合可见范围。 现在,我想添加一些纯粹用于定向的线条,它们不一定需要在全尺寸的可见范围内。是否可以告诉 matplotlibnot 为某些绘图对象调整 xlimylim

【问题讨论】:

    标签: matplotlib


    【解决方案1】:

    您可以使用 state-machine(doc) 或 OO (doc) 接口关闭自动缩放。

    ax = plt.gca()
    ax.plot(arange(15))
    plt.draw() # it will re-scale here
    ax.autoscale(False)
    ax.plot(arange(15) ** 2)
    ax.draw() # will not rescale
    

    【讨论】:

      猜你喜欢
      • 2012-06-14
      • 2012-07-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多