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

« back to all changes in this revision

Viewing changes to examples/demo/toolbar_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
 
"""Toolbar Plot
2
 
 
3
 
A toolbar plot is the same as a regular Plot, but also provides a 
4
 
usually hidden drop-down toolbar with configurable buttons.
5
 
 
6
 
The toolbar appears when the mouse hovers over the top of the plot area.
7
 
 
8
 
This toolbar provides buttons for X log scale, Y log scale, Save as,
9
 
Copy image, Copy data, and Zoom reset.
10
 
 
11
 
"""
12
 
 
13
 
import numpy
14
 
 
15
 
from chaco.plot import Plot, ArrayPlotData
16
 
from chaco.api import ToolbarPlot
17
 
from enable.api import ComponentEditor
18
 
from traits.api import Instance, HasTraits
19
 
from traitsui.api import View, Item
20
 
 
21
 
 
22
 
class ExamplePlotApp(HasTraits):
23
 
 
24
 
    plot = Instance(Plot)
25
 
 
26
 
    traits_view = View(Item('plot', editor=ComponentEditor(),
27
 
                            width = 600, height = 600,
28
 
                            show_label=False),
29
 
                            resizable=True)
30
 
 
31
 
    def __init__(self, index, series1, series2, **kw):
32
 
        super(ExamplePlotApp, self).__init__(**kw)
33
 
        plot_data = ArrayPlotData(index=index)
34
 
        plot_data.set_data('series1', series1)
35
 
        plot_data.set_data('series2', series2)
36
 
 
37
 
        self.plot = ToolbarPlot(plot_data)
38
 
        self.plot.plot(('index', 'series1'), color='auto')
39
 
        self.plot.plot(('index', 'series2'), color='auto')
40
 
 
41
 
index = numpy.arange(1.0, 10., 0.01)
42
 
series1 = (100.0 + index) / (100.0 - 20*index**2 + 5.0*index**4)
43
 
series2 = (100.0 + index) / (100.0 - 20*index**2 + 5.0*index**3)
44
 
demo = ExamplePlotApp(index, series1, series2)
45
 
 
46
 
if __name__== '__main__':
47
 
    demo.configure_traits()