3

I'm using a chaco scatter plot with a PanTool and a ZoomTool. After interacting with the plot via panning and zooming, I'd like to have a button to reset the plot to its default state, basically like the matplotlib home button. I've searched through the documentation and explored many methods and parameters of chaco.plot.Plot and chaco.axis.PlotAxis but haven't been able to figure this out.

4

1 回答 1

3

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

# 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)
于 2013-07-18T01:34:34.093 回答