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

« back to all changes in this revision

Viewing changes to examples/tutorials/tutorial8.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
 
"""Tutorial 8. Putting two plots on the screen
2
 
 
3
 
This tutorial sets up for showing how Chaco allows easily opening multiple
4
 
views into a single dataspace, which is demonstrated in later tutorials.
5
 
"""
6
 
 
7
 
from scipy import arange
8
 
from scipy.special import jn
9
 
 
10
 
from enable.api import ComponentEditor
11
 
from traits.api import HasTraits, Instance
12
 
from traitsui.api import Item, View
13
 
 
14
 
from chaco.api import create_line_plot, HPlotContainer
15
 
from chaco.tools.api import PanTool
16
 
 
17
 
 
18
 
class PlotExample(HasTraits):
19
 
    container = Instance(HPlotContainer)
20
 
 
21
 
    traits_view = View(Item('container', editor=ComponentEditor(),
22
 
                            show_label=False, width=800, height=600),
23
 
                       title="Chaco Tutorial")
24
 
 
25
 
    def _container_default(self):
26
 
        x = arange(-5.0, 15.0, 20.0/100)
27
 
 
28
 
        y = jn(0, x)
29
 
        left_plot = create_line_plot((x,y), bgcolor="white",
30
 
                                     add_grid=True, add_axis=True)
31
 
        left_plot.tools.append(PanTool(left_plot))
32
 
        self.left_plot = left_plot
33
 
 
34
 
        y = jn(1, x)
35
 
        right_plot = create_line_plot((x,y), bgcolor="white",
36
 
                                      add_grid=True, add_axis=True)
37
 
        right_plot.tools.append(PanTool(right_plot))
38
 
        right_plot.y_axis.orientation = "right"
39
 
        self.right_plot = right_plot
40
 
 
41
 
        # Tone down the colors on the grids
42
 
        right_plot.hgrid.line_color = (0.3,0.3,0.3,0.5)
43
 
        right_plot.vgrid.line_color = (0.3,0.3,0.3,0.5)
44
 
        left_plot.hgrid.line_color = (0.3,0.3,0.3,0.5)
45
 
        left_plot.vgrid.line_color = (0.3,0.3,0.3,0.5)
46
 
 
47
 
        container = HPlotContainer(spacing=20, padding=50, bgcolor="lightgray")
48
 
        container.add(left_plot)
49
 
        container.add(right_plot)
50
 
        return container
51
 
 
52
 
demo = PlotExample()
53
 
 
54
 
if __name__ == "__main__":
55
 
    demo.configure_traits()