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

« back to all changes in this revision

Viewing changes to examples/tutorials/scipy2008/tools.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 chaco.api import ArrayPlotData, Plot
5
 
from chaco.tools.api import PanTool, ZoomTool, DragZoom
6
 
from enable.component_editor import ComponentEditor
7
 
from traits.api import HasTraits, Instance
8
 
from traitsui.api import Item, View
9
 
 
10
 
class ToolsExample(HasTraits):
11
 
 
12
 
    plot = Instance(Plot)
13
 
    traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False),
14
 
                       width=800, height=600, resizable=True,
15
 
                       title="Pan & Zoom")
16
 
 
17
 
    def __init__(self):
18
 
        # Create the data and the PlotData object
19
 
        x = linspace(-14, 14, 500)
20
 
        y = sin(x) * x**3
21
 
        plotdata = ArrayPlotData(x = x, y = y)
22
 
        # Create a Plot and associate it with the PlotData
23
 
        plot = Plot(plotdata)
24
 
        # Create a line plot in the Plot
25
 
        plot.plot(("x", "y"), type="line", color="blue")
26
 
        # Add the pan and zoom tools
27
 
        plot.tools.append(PanTool(plot))
28
 
        plot.tools.append(ZoomTool(plot))
29
 
        plot.tools.append(DragZoom(plot, drag_button="right"))
30
 
        self.plot = plot
31
 
 
32
 
#===============================================================================
33
 
# demo object that is used by the demo.py application.
34
 
#===============================================================================
35
 
demo = ToolsExample()
36
 
 
37
 
if __name__ == "__main__":
38
 
    demo.configure_traits()
39