2
from numpy import linspace, sin
4
from chaco.api import ArrayPlotData, HPlotContainer, Plot
5
from chaco.tools.api import PanTool, ZoomTool
6
from enable.component_editor import ComponentEditor
7
from traits.api import HasTraits, Instance
8
from traitsui.api import Item, View
10
class FlippedExample(HasTraits):
12
container = Instance(HPlotContainer)
14
traits_view = View(Item('container', editor=ComponentEditor(), show_label=False),
15
width=1000, height=600, resizable=True,
16
title="Connected Range, Flipped")
19
# Create the data and the PlotData object
20
x = linspace(-14, 14, 100)
22
plotdata = ArrayPlotData(x = x, y = y)
24
# Create the scatter plot
25
scatter = Plot(plotdata)
26
scatter.plot(("x", "y"), type="scatter", color="blue")
28
# Create the line plot, rotated and vertically oriented
29
line = Plot(plotdata, orientation="v", default_origin="top left")
30
line.plot(("x", "y"), type="line", color="blue")
32
# Create a horizontal container and put the two plots inside it
33
self.container = HPlotContainer(scatter, line)
35
# Add pan/zoom so we can see they are connected
36
scatter.tools.append(PanTool(scatter))
37
scatter.tools.append(ZoomTool(scatter))
38
line.tools.append(PanTool(line))
39
line.tools.append(ZoomTool(line))
41
# Set the two plots' ranges to be the same
42
scatter.range2d = line.range2d
44
#===============================================================================
45
# demo object that is used by the demo.py application.
46
#===============================================================================
47
demo = FlippedExample()
48
if __name__ == "__main__":
49
demo.configure_traits()