【问题标题】:How to restore chaco plot axes to default settings after using tools?使用工具后如何将 chaco 绘图轴恢复为默认设置?
【发布时间】:2013-07-15 21:02:38
【问题描述】:

我正在使用带有 PanTool 和 ZoomTool 的 chaco 散点图。通过平移和缩放与绘图交互后,我想要一个按钮将绘图重置为其默认状态,基本上就像 matplotlib 主页按钮。我搜索了文档并探索了 chaco.plot.Plot 和 chaco.axis.PlotAxis 的许多方法和参数,但一直无法弄清楚。

【问题讨论】:

    标签: enthought chaco


    【解决方案1】:

    找到了可行的方法。首先,在设置绘图数据并创建绘图后,缓存轴的低值和高值,如下所示:

    # cache default axes limits
    x_lo = plot.x_axis.mapper.range.low
    x_hi = plot.x_axis.mapper.range.high
    y_lo = plot.y_axis.mapper.range.low
    y_hi = plot.y_axis.mapper.range.high
    

    用户操作绘图后,例如使用 PanTool 和 ZoomTool,可以像这样重置轴:

    # reset plot to original form
    plot.x_axis.mapper.range.set(low=x_lo, high=x_hi)
    plot.y_axis.mapper.range.set(low=y_lo, high=y_hi)
    

    【讨论】:

      猜你喜欢
      • 2018-02-12
      • 2016-06-24
      • 2015-11-27
      • 2014-04-04
      • 2016-08-27
      • 1970-01-01
      • 2020-07-09
      • 2014-12-12
      • 1970-01-01
      相关资源
      最近更新 更多