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

« back to all changes in this revision

Viewing changes to examples/demo/simple_polar.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
 
Draws a static polar plot.
3
 
"""
4
 
 
5
 
# Major library imports
6
 
from numpy import arange, pi, cos
7
 
 
8
 
# Enthought library imports
9
 
from enable.api import Component, ComponentEditor
10
 
from traits.api import HasTraits, Instance
11
 
from traitsui.api import Item, Group, View
12
 
 
13
 
# Chaco imports
14
 
from chaco.api import create_polar_plot
15
 
 
16
 
#===============================================================================
17
 
# # Create the Chaco plot.
18
 
#===============================================================================
19
 
def _create_plot_component():
20
 
 
21
 
    # Create theta data
22
 
    numpoints = 5000
23
 
    low = 0
24
 
    high = 2*pi
25
 
    theta = arange(low, high, (high-low) / numpoints)
26
 
 
27
 
    # Create the radius data
28
 
    radius = cos(3*theta)
29
 
 
30
 
    # Create a new polar plot with radius and theta data
31
 
    plot = create_polar_plot((radius,theta),color=(0.0,0.0,1.0,1), width=4.0)
32
 
 
33
 
    return plot
34
 
 
35
 
#===============================================================================
36
 
# Attributes to use for the plot view.
37
 
size=(600,600)
38
 
title="Simple Polar Plot"
39
 
 
40
 
#===============================================================================
41
 
# # Demo class that is used by the demo.py application.
42
 
#===============================================================================
43
 
class Demo(HasTraits):
44
 
    plot = Instance(Component)
45
 
 
46
 
    traits_view = View(
47
 
                    Group(
48
 
                        Item('plot', editor=ComponentEditor(size=size),
49
 
                             show_label=False),
50
 
                        orientation = "vertical"),
51
 
                    resizable=True, title=title,
52
 
                    width=size[0], height=size[1]
53
 
                    )
54
 
 
55
 
    def _plot_default(self):
56
 
         return _create_plot_component()
57
 
 
58
 
demo = Demo()
59
 
 
60
 
if __name__ == "__main__":
61
 
    demo.configure_traits()
62
 
 
63
 
# EOF#######################