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

« back to all changes in this revision

Viewing changes to examples/tutorials/scipy2008/data_chooser.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
 
 
2
 
from numpy import linspace
3
 
from scipy.special import jn
4
 
 
5
 
from chaco.api import ArrayPlotData, Plot
6
 
from enable.component_editor import ComponentEditor
7
 
from traits.api import Dict, Enum, HasTraits, Instance
8
 
from traitsui.api import Item, View
9
 
 
10
 
class DataChooser(HasTraits):
11
 
 
12
 
    plot = Instance(Plot)
13
 
    data_name = Enum("jn0", "jn1", "jn2")
14
 
    traits_view = View(Item('data_name', label="Y data"),
15
 
                       Item('plot', editor=ComponentEditor(), show_label=False),
16
 
                       width=800, height=600, resizable=True,
17
 
                       title="Data Chooser")
18
 
 
19
 
    def __init__(self):
20
 
        x = linspace(-5, 10, 100)
21
 
        self.data = {"jn0": jn(0, x),
22
 
                     "jn1": jn(1, x),
23
 
                     "jn2": jn(2, x)}
24
 
 
25
 
        # Create the data and the PlotData object
26
 
        self.plotdata = ArrayPlotData(x=x, y=self.data["jn0"])
27
 
 
28
 
        # Create a Plot and associate it with the PlotData
29
 
        plot = Plot(self.plotdata)
30
 
        # Create a line plot in the Plot
31
 
        plot.plot(("x", "y"), type="line", color="blue")
32
 
        self.plot = plot
33
 
 
34
 
    def _data_name_changed(self, old, new):
35
 
        self.plotdata.set_data("y", self.data[self.data_name])
36
 
 
37
 
 
38
 
#===============================================================================
39
 
# demo object that is used by the demo.py application.
40
 
#===============================================================================
41
 
demo=DataChooser()
42
 
if __name__ == "__main__":
43
 
    demo.configure_traits()
44