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

« back to all changes in this revision

Viewing changes to examples/demo/domain_limits.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import numpy
2
 
 
3
 
from chaco.plot import Plot, ArrayPlotData
4
 
from chaco.api import ToolbarPlot
5
 
from chaco.tools.api import PanTool, ZoomTool
6
 
from enable.api import ComponentEditor
7
 
from traits.api import Instance, HasTraits
8
 
from traitsui.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()