1
"""This example demonstrates customizing a plot object with a plot tool
2
using the chaco.shell subpackage.
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.
8
# Major library imports
9
from numpy import linspace, meshgrid, sin
11
# Enthought library imports
12
from chaco.shell import show, title, pcolor, colormap, curplot
13
from chaco.default_colormaps import jet
15
# Crate some scalar data
16
xs = linspace(0,10,200)
17
ys = linspace(0,20,400)
21
# Create a pseudo-color-map
22
pcolor(x, y, z, name='sin_x_times_y')
24
# Change the color mapping
28
title("pseudo colormap image plot")
31
# From the current plot object, grab the first plot
32
img_plot = curplot().plots['sin_x_times_y'][0]
34
# Add a custom tool - in this case, an ImageInspector
35
from chaco.tools.api import ImageInspectorTool, ImageInspectorOverlay
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)
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.