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

« back to all changes in this revision

Viewing changes to examples/demo/shell/add_tool.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
 
"""This example demonstrates customizing a plot object with a plot tool
2
 
using the chaco.shell subpackage.
3
 
 
4
 
The functions in the chaco.shell package allow us to quickly generate plots
5
 
with some basic interactivity without using the object-oriented core of Chaco.
6
 
"""
7
 
 
8
 
# Major library imports
9
 
from numpy import linspace, meshgrid, sin
10
 
 
11
 
# Enthought library imports
12
 
from chaco.shell import show, title, pcolor, colormap, curplot
13
 
from chaco.default_colormaps import jet
14
 
 
15
 
# Crate some scalar data
16
 
xs = linspace(0,10,200)
17
 
ys = linspace(0,20,400)
18
 
x,y = meshgrid(xs,ys)
19
 
z = sin(x)*y
20
 
 
21
 
# Create a pseudo-color-map
22
 
pcolor(x, y, z, name='sin_x_times_y')
23
 
 
24
 
# Change the color mapping
25
 
colormap(jet)
26
 
 
27
 
# Add some titles
28
 
title("pseudo colormap image plot")
29
 
 
30
 
 
31
 
# From the current plot object, grab the first plot
32
 
img_plot = curplot().plots['sin_x_times_y'][0]
33
 
 
34
 
# Add a custom tool - in this case, an ImageInspector
35
 
from chaco.tools.api import ImageInspectorTool, ImageInspectorOverlay
36
 
 
37
 
tool = ImageInspectorTool(img_plot)
38
 
img_plot.tools.append(tool)
39
 
overlay = ImageInspectorOverlay(img_plot, image_inspector=tool,
40
 
                                bgcolor="white", border_visible=True)
41
 
img_plot.overlays.append(overlay)
42
 
 
43
 
 
44
 
# If running this from the command line and outside of a wxPython
45
 
# application or process, the show() command is necessary to keep
46
 
# the plot from disappearing instantly.  If a wxPython mainloop
47
 
# is already running, then this command is not necessary.
48
 
show()