2
from numpy import linspace
3
from scipy.special import jn
5
from chaco.api import ArrayPlotData, Plot
6
from enable.component_editor import ComponentEditor
7
from traits.api import Dict, Enum, HasTraits, Instance
8
from traitsui.api import Item, View
10
class DataChooser(HasTraits):
13
data_name = Enum("jn0", "jn1", "jn2")
14
traits_view = View(Item('data_name', label="Y data"),
15
Item('plot', editor=ComponentEditor(), show_label=False),
16
width=800, height=600, resizable=True,
20
x = linspace(-5, 10, 100)
21
self.data = {"jn0": jn(0, x),
25
# Create the data and the PlotData object
26
self.plotdata = ArrayPlotData(x=x, y=self.data["jn0"])
28
# Create a Plot and associate it with the PlotData
29
plot = Plot(self.plotdata)
30
# Create a line plot in the Plot
31
plot.plot(("x", "y"), type="line", color="blue")
34
def _data_name_changed(self, old, new):
35
self.plotdata.set_data("y", self.data[self.data_name])
38
#===============================================================================
39
# demo object that is used by the demo.py application.
40
#===============================================================================
42
if __name__ == "__main__":
43
demo.configure_traits()