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

« back to all changes in this revision

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