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

« back to all changes in this revision

Viewing changes to examples/tutorials/scipy2008/traits_example.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, sin
3
 
 
4
 
from enable.api import ColorTrait
5
 
from chaco.api import ArrayPlotData, Plot, marker_trait
6
 
from enable.component_editor import ComponentEditor
7
 
from traits.api import HasTraits, Instance, Int
8
 
from traitsui.api import Group, Item, View
9
 
 
10
 
class ScatterPlotTraits(HasTraits):
11
 
 
12
 
    plot = Instance(Plot)
13
 
    color = ColorTrait("blue")
14
 
    marker = marker_trait
15
 
    marker_size = Int(4)
16
 
 
17
 
    traits_view = View(
18
 
        Group(Item('color', label="Color", style="custom"),
19
 
            Item('marker', label="Marker"),
20
 
            Item('marker_size', label="Size"),
21
 
            Item('plot', editor=ComponentEditor(), show_label=False),
22
 
            orientation = "vertical"),
23
 
                    width=800, height=600, resizable=True,
24
 
                    title="Chaco Plot"
25
 
                    )
26
 
 
27
 
    def __init__(self):
28
 
        # Create the data and the PlotData object
29
 
        x = linspace(-14, 14, 100)
30
 
        y = sin(x) * x**3
31
 
        plotdata = ArrayPlotData(x = x, y = y)
32
 
        # Create a Plot and associate it with the PlotData
33
 
        plot = Plot(plotdata)
34
 
        # Create a line plot in the Plot
35
 
        self.renderer = plot.plot(("x", "y"), type="scatter", color="blue")[0]
36
 
        self.plot = plot
37
 
 
38
 
    def _color_changed(self):
39
 
        self.renderer.color = self.color
40
 
 
41
 
    def _marker_changed(self):
42
 
        self.renderer.marker = self.marker
43
 
 
44
 
    def _marker_size_changed(self):
45
 
        self.renderer.marker_size = self.marker_size
46
 
 
47
 
#===============================================================================
48
 
# demo object that is used by the demo.py application.
49
 
#===============================================================================
50
 
demo = ScatterPlotTraits()
51
 
 
52
 
if __name__ == "__main__":
53
 
    demo.configure_traits()
54