3
from enthought.chaco.plot import Plot, ArrayPlotData
4
from enthought.chaco.api import ToolbarPlot
5
from enthought.chaco.tools.api import PanTool, ZoomTool
6
from enthought.enable.api import ComponentEditor
7
from enthought.traits.api import Instance, HasTraits
8
from enthought.traits.ui.api import View, Item
11
class ExamplePlotApp(HasTraits):
15
traits_view = View(Item('plot', editor=ComponentEditor(),
16
width = 600, height = 600,
20
def __init__(self, index, series1, series2, **kw):
21
super(ExamplePlotApp, self).__init__(**kw)
22
plot_data = ArrayPlotData(index=index)
23
plot_data.set_data('series1', series1)
24
plot_data.set_data('series2', series2)
26
self.plot = ToolbarPlot(plot_data)
27
line_plot = self.plot.plot(('index', 'series1'), color='auto')[0]
29
# Add pan and zoom tools
30
line_plot.tools.append(PanTool(line_plot))
31
line_plot.tools.append(ZoomTool(line_plot))
33
# Set the domain_limits
34
line_plot.index_mapper.domain_limits = (3.3, 6.6)
36
index = numpy.arange(1.0, 10., 0.01)
37
series1 = (100.0 + index) / (100.0 - 20*index**2 + 5.0*index**4)
38
series2 = (100.0 + index) / (100.0 - 20*index**2 + 5.0*index**3)
39
demo = ExamplePlotApp(index, series1, series2)
41
if __name__== '__main__':
42
demo.configure_traits()