def _create_plot_component(): # Create some x-y data series to plot x = linspace(1.0, 8.0, 200) pd = ArrayPlotData(index=x) pd.set_data("y0", sqrt(x)) pd.set_data("y1", x) pd.set_data("y2", x**2) pd.set_data("y3", exp(x)) pd.set_data("y4", gamma(x)) pd.set_data("y5", x**x) # Create some line plots of some of the data plot = Plot(pd) plot.plot(("index", "y0"), line_width=2, name="sqrt(x)", color="purple") plot.plot(("index", "y1"), line_width=2, name="x", color="blue") plot.plot(("index", "y2"), line_width=2, name="x**2", color="green") plot.plot(("index", "y3"), line_width=2, name="exp(x)", color="gold") plot.plot(("index", "y4"), line_width=2, name="gamma(x)", color="orange") plot.plot(("index", "y5"), line_width=2, name="x**x", color="red") # Set the value axis to display on a log scale plot.value_scale = "log" # Tweak some of the plot properties plot.title = "Log Plot" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(1.0, 8.0, 200) pd = ArrayPlotData(index = x) pd.set_data("y0", sqrt(x)) pd.set_data("y1", x) pd.set_data("y2", x**2) pd.set_data("y3", exp(x)) pd.set_data("y4", gamma(x)) pd.set_data("y5", x**x) # Create some line plots of some of the data plot = Plot(pd) plot.plot(("index", "y0"), line_width=2, name="sqrt(x)", color="purple") plot.plot(("index", "y1"), line_width=2, name="x", color="blue") plot.plot(("index", "y2"), line_width=2, name="x**2", color="green") plot.plot(("index", "y3"), line_width=2, name="exp(x)", color="gold") plot.plot(("index", "y4"), line_width=2, name="gamma(x)",color="orange") plot.plot(("index", "y5"), line_width=2, name="x**x", color="red") # Set the value axis to display on a log scale plot.value_scale = "log" # Tweak some of the plot properties plot.title = "Log Plot" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def __init__(self, **traits): super(MYOGrapher, self).__init__(**traits) data_EMG = ArrayPlotData(x=[0], sEMG1=[0], sEMG2=[0], sEMG3=[0], sEMG4=[0], sEMG5=[0], sEMG6=[0], sEMG7=[0], sEMG8=[0]) data_Angle = ArrayPlotData(x=[0], myo1=[0], myo2=[0]) plot_Angle = Plot(data_Angle) plot_EMG = Plot(data_EMG) plot_EMG.plot(("x", "sEMG1"), type="line") plot_EMG.title = "sEMG" plot_EMG.value_scale = 'linear' plot_Angle.plot(("x", "myo1"), type="line") plot_Angle.title = "Angle" plot_Angle.value_scale = 'linear' self.plot_EMG = plot_EMG self.data_EMG = data_EMG self.plot_Angle = plot_Angle self.data_Angle = data_Angle self.sEMG_names = [ 'sEMG1', 'sEMG2', 'sEMG3', 'sEMG4', 'sEMG5', 'sEMG6', 'sEMG7', 'sEMG8' ] self.Angle_names = ['myo1', 'myo2'] self.emg_posit = 0 self.angle_posit = 0 _stream_emg = [] _stream_angle = [] for chanel in range(8): _stream_emg.append(np.zeros(self.sEMG_length)) self.stream_emg = _stream_emg for _myos_in in range(2): _stream_angle.append(np.zeros(self.Angle_length)) self.stream_emg = _stream_emg self.stream_Angle = _stream_angle self.EMG_StreamWin = np.zeros(self.window_size) self.Angle_StreamWin = np.zeros(self.window_size)
def __init__(self,**traits): super(MYOGrapher, self).__init__(**traits) data_EMG = ArrayPlotData(x=[0],sEMG1=[0],sEMG2=[0],sEMG3=[0], sEMG4=[0],sEMG5=[0],sEMG6=[0],sEMG7=[0],sEMG8=[0]) data_Angle = ArrayPlotData(x=[0],myo1=[0],myo2=[0]) plot_Angle = Plot(data_Angle) plot_EMG = Plot(data_EMG) plot_EMG.plot(("x","sEMG1"),type="line") plot_EMG.title = "sEMG" plot_EMG.value_scale = 'linear' plot_Angle.plot(("x","myo1"),type="line") plot_Angle.title = "Angle" plot_Angle.value_scale = 'linear' self.plot_EMG = plot_EMG self.data_EMG = data_EMG self.plot_Angle = plot_Angle self.data_Angle = data_Angle self.sEMG_names = ['sEMG1','sEMG2','sEMG3', 'sEMG4','sEMG5','sEMG6','sEMG7','sEMG8'] self.Angle_names = ['myo1','myo2'] self.emg_posit = 0 self.angle_posit = 0 _stream_emg = [] _stream_angle = [] for chanel in range(8): _stream_emg.append(np.zeros(self.sEMG_length)) self.stream_emg = _stream_emg for _myos_in in range(2): _stream_angle.append(np.zeros(self.Angle_length)) self.stream_emg = _stream_emg self.stream_Angle = _stream_angle self.EMG_StreamWin = np.zeros(self.window_size) self.Angle_StreamWin = np.zeros(self.window_size)