3
Draws a colormapped image plot
4
- Left-drag pans the plot.
5
- Mousewheel up and down zooms the plot in and out.
6
- Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular
7
region to zoom. If you use a sequence of zoom boxes, pressing alt-left-arrow
8
and alt-right-arrow moves you forwards and backwards through the "zoom
12
# Major library imports
13
from numpy import exp, linspace, meshgrid
15
# Enthought library imports
16
from enable.api import Component, ComponentEditor
17
from traits.api import HasTraits, Instance
18
from traitsui.api import Item, Group, View
21
from chaco.api import ArrayPlotData, jet, Plot
22
from chaco.tools.api import PanTool, ZoomTool
24
#===============================================================================
25
# # Create the Chaco plot.
26
#===============================================================================
27
def _create_plot_component():
28
# Create a scalar field to colormap
29
xs = linspace(0, 10, 600)
30
ys = linspace(0, 5, 600)
31
x, y = meshgrid(xs,ys)
32
z = exp(-(x**2+y**2)/100)
34
# Create a plot data obect and give it this data
36
pd.set_data("imagedata", z)
40
img_plot = plot.img_plot("imagedata",
45
# Tweak some of the plot properties
46
plot.title = "My First Image Plot"
49
# Attach some tools to the plot
50
plot.tools.append(PanTool(plot))
51
zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False)
52
img_plot.overlays.append(zoom)
56
#===============================================================================
57
# Attributes to use for the plot view.
59
title="Basic Colormapped Image Plot"
61
#===============================================================================
62
# # Demo class that is used by the demo.py application.
63
#===============================================================================
64
class Demo(HasTraits):
65
plot = Instance(Component)
69
Item('plot', editor=ComponentEditor(size=size),
71
orientation = "vertical"),
72
resizable=True, title=title
74
def _plot_default(self):
75
return _create_plot_component()
79
if __name__ == "__main__":
80
demo.configure_traits()