2
from numpy import linspace, sin
4
from chaco.api import ArrayPlotData, Plot
5
from enable.api import BaseTool
6
from enable.component_editor import ComponentEditor
7
from traits.api import Enum, HasTraits, Instance
8
from traitsui.api import Item, View
10
class CustomTool(BaseTool):
12
def normal_mouse_move(self, event):
13
print "Screen point:", event.x, event.y
15
class ScatterPlot(HasTraits):
19
traits_view = View(Item('plot', editor=ComponentEditor(), show_label=False),
20
width=800, height=600, resizable=True,
23
def _plot_default(self):
24
# Create the data and the PlotData object
25
x = linspace(-14, 14, 100)
27
plotdata = ArrayPlotData(x = x, y = y)
28
# Create a Plot and associate it with the PlotData
30
# Create a scatter plot in the Plot
31
plot.plot(("x", "y"), type="scatter", color="blue")
32
# Add our custom tool to the plot
33
plot.tools.append(CustomTool(plot))
36
#===============================================================================
37
# demo object that is used by the demo.py application.
38
#===============================================================================
40
if __name__ == "__main__":
41
demo.edit_traits(kind="livemodal")