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

« back to all changes in this revision

Viewing changes to examples/tutorials/scipy2008/connected_orientation.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, HPlotContainer, Plot
5
 
from chaco.tools.api import PanTool, ZoomTool
6
 
from enable.component_editor import ComponentEditor
7
 
from traits.api import HasTraits, Instance
8
 
from traitsui.api import Item, View
9
 
 
10
 
class FlippedExample(HasTraits):
11
 
 
12
 
    container = Instance(HPlotContainer)
13
 
 
14
 
    traits_view = View(Item('container', editor=ComponentEditor(), show_label=False),
15
 
                       width=1000, height=600, resizable=True,
16
 
                       title="Connected Range, Flipped")
17
 
 
18
 
    def __init__(self):
19
 
        # Create the data and the PlotData object
20
 
        x = linspace(-14, 14, 100)
21
 
        y = sin(x) * x**3
22
 
        plotdata = ArrayPlotData(x = x, y = y)
23
 
 
24
 
        # Create the scatter plot
25
 
        scatter = Plot(plotdata)
26
 
        scatter.plot(("x", "y"), type="scatter", color="blue")
27
 
 
28
 
        # Create the line plot, rotated and vertically oriented
29
 
        line = Plot(plotdata, orientation="v", default_origin="top left")
30
 
        line.plot(("x", "y"), type="line", color="blue")
31
 
 
32
 
        # Create a horizontal container and put the two plots inside it
33
 
        self.container = HPlotContainer(scatter, line)
34
 
 
35
 
        # Add pan/zoom so we can see they are connected
36
 
        scatter.tools.append(PanTool(scatter))
37
 
        scatter.tools.append(ZoomTool(scatter))
38
 
        line.tools.append(PanTool(line))
39
 
        line.tools.append(ZoomTool(line))
40
 
 
41
 
        # Set the two plots' ranges to be the same
42
 
        scatter.range2d = line.range2d
43
 
 
44
 
#===============================================================================
45
 
# demo object that is used by the demo.py application.
46
 
#===============================================================================
47
 
demo = FlippedExample()
48
 
if __name__ == "__main__":
49
 
    demo.configure_traits()