2
from numpy import linspace, sin
4
from chaco.api import ArrayPlotData, Plot
5
from chaco.tools.api import PanTool, ZoomTool, DragZoom
6
from enable.component_editor import ComponentEditor
7
from traits.api import HasTraits, Instance
8
from traitsui.api import Item, View
10
class ToolsExample(HasTraits):
13
traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False),
14
width=800, height=600, resizable=True,
18
# Create the data and the PlotData object
19
x = linspace(-14, 14, 500)
21
plotdata = ArrayPlotData(x = x, y = y)
22
# Create a Plot and associate it with the PlotData
24
# Create a line plot in the Plot
25
plot.plot(("x", "y"), type="line", color="blue")
26
# Add the pan and zoom tools
27
plot.tools.append(PanTool(plot))
28
plot.tools.append(ZoomTool(plot))
29
plot.tools.append(DragZoom(plot, drag_button="right"))
32
#===============================================================================
33
# demo object that is used by the demo.py application.
34
#===============================================================================
37
if __name__ == "__main__":
38
demo.configure_traits()