~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to examples/domain_limits.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import numpy
 
2
 
 
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
 
9
 
 
10
 
 
11
class ExamplePlotApp(HasTraits):
 
12
 
 
13
    plot = Instance(Plot)
 
14
 
 
15
    traits_view = View(Item('plot', editor=ComponentEditor(),
 
16
                            width = 600, height = 600,
 
17
                            show_label=False),
 
18
                            resizable=True)
 
19
 
 
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)
 
25
 
 
26
        self.plot = ToolbarPlot(plot_data)
 
27
        line_plot = self.plot.plot(('index', 'series1'), color='auto')[0]
 
28
 
 
29
        # Add pan and zoom tools
 
30
        line_plot.tools.append(PanTool(line_plot))
 
31
        line_plot.tools.append(ZoomTool(line_plot))
 
32
        
 
33
        # Set the domain_limits
 
34
        line_plot.index_mapper.domain_limits = (3.3, 6.6)
 
35
 
 
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)
 
40
 
 
41
if __name__== '__main__':
 
42
    demo.configure_traits()