2
from numpy import linspace, sin
4
from enable.api import ColorTrait
5
from chaco.api import ArrayPlotData, Plot, marker_trait
6
from enable.component_editor import ComponentEditor
7
from traits.api import HasTraits, Instance, Int
8
from traitsui.api import Group, Item, View
10
class ScatterPlotTraits(HasTraits):
13
color = ColorTrait("blue")
18
Group(Item('color', label="Color", style="custom"),
19
Item('marker', label="Marker"),
20
Item('marker_size', label="Size"),
21
Item('plot', editor=ComponentEditor(), show_label=False),
22
orientation = "vertical"),
23
width=800, height=600, resizable=True,
28
# Create the data and the PlotData object
29
x = linspace(-14, 14, 100)
31
plotdata = ArrayPlotData(x = x, y = y)
32
# Create a Plot and associate it with the PlotData
34
# Create a line plot in the Plot
35
self.renderer = plot.plot(("x", "y"), type="scatter", color="blue")[0]
38
def _color_changed(self):
39
self.renderer.color = self.color
41
def _marker_changed(self):
42
self.renderer.marker = self.marker
44
def _marker_size_changed(self):
45
self.renderer.marker_size = self.marker_size
47
#===============================================================================
48
# demo object that is used by the demo.py application.
49
#===============================================================================
50
demo = ScatterPlotTraits()
52
if __name__ == "__main__":
53
demo.configure_traits()