2
from numpy import linspace
3
from scipy.special import jn
5
from enthought.chaco.api import ArrayPlotData, Plot
6
from enthought.enable.component_editor import ComponentEditor
7
from enthought.traits.api import Dict, Enum, HasTraits, Instance
8
from enthought.traits.ui.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
if __name__ == "__main__":
39
DataChooser().configure_traits()