def plot_signal(self): if self.signal_plot is not None: self.signal_plot.plot() return # Create the figure self.xlabel = '%s' % str(self.axes_manager.signal_axes[0]) if self.axes_manager.signal_axes[0].units is not Undefined: self.xlabel += ' (%s)' % self.axes_manager.signal_axes[0].units self.ylabel = 'Intensity' self.axis = self.axes_manager.signal_axes[0].axis sf = spectrum.SpectrumFigure(title=self.signal_title + " Signal") sf.xlabel = self.xlabel sf.ylabel = self.ylabel sf.axis = self.axis sf.create_axis() sf.axes_manager = self.axes_manager self.signal_plot = sf # Create a line to the left axis with the default indices sl = spectrum.SpectrumLine() sl.autoscale = True sl.data_function = self.signal_data_function sl.plot_indices = True if self.pointer is not None: color = self.pointer.color else: color = 'red' sl.set_line_properties(color=color, type='step') # Add the line to the figure sf.add_line(sl) # If the data is complex create a line in the left axis with the # default coordinates sl = spectrum.SpectrumLine() sl.data_function = self.signal_data_function sl.plot_coordinates = True sl.get_complex = any(np.iscomplex(sl.data_function())) if sl.get_complex: sl.set_line_properties(color="blue", type='step') # Add extra line to the figure sf.add_line(sl) self.signal_plot = sf sf.plot() if self.navigator_plot is not None and sf.figure is not None: utils.on_figure_window_close(self.navigator_plot.figure, self._on_navigator_plot_closing) utils.on_figure_window_close(sf.figure, self.close_navigator_plot) self._key_nav_cid = \ self.signal_plot.figure.canvas.mpl_connect( 'key_press_event', self.axes_manager.key_navigator) self._key_nav_cid = \ self.navigator_plot.figure.canvas.mpl_connect( 'key_press_event', self.axes_manager.key_navigator) self.signal_plot.figure.canvas.mpl_connect( 'key_press_event', self.key2switch_right_pointer) self.navigator_plot.figure.canvas.mpl_connect( 'key_press_event', self.key2switch_right_pointer)
def plot_navigator(self): if self.axes_manager.navigation_dimension == 0: return if self.navigator_data_function is None: navigation_sliders(self.axes_manager.navigation_axes, title=self.signal_title + " navigation sliders") return if self.navigator_plot is not None: self.navigator_plot.plot() return elif len(self.navigator_data_function().shape) == 1: # Create the figure sf = spectrum.SpectrumFigure( title=self.signal_title + ' Navigator' if self.signal_title else "") axis = self.axes_manager.navigation_axes[0] sf.xlabel = '%s' % str(axis) if axis.units is not Undefined: sf.xlabel += ' (%s)' % axis.units sf.ylabel = r'$\Sigma\mathrm{data\,over\,all\,other\,axes}$' sf.axis = axis.axis sf.axes_manager = self.axes_manager self.navigator_plot = sf # Create a line to the left axis with the default # indices sl = spectrum.SpectrumLine() sl.data_function = self.navigator_data_function sl.set_line_properties(color='blue', type='step') # Add the line to the figure sf.add_line(sl) sf.plot() self.pointer.add_axes(sf.ax) if self.axes_manager.navigation_dimension > 1: navigation_sliders(self.axes_manager.navigation_axes, title=self.signal_title + " navigation sliders") for axis in self.axes_manager.navigation_axes[:-2]: axis.connect(sf.update) self.navigator_plot = sf elif len(self.navigator_data_function().shape) >= 2: imf = image.ImagePlot() imf.data_function = self.navigator_data_function # Navigator labels if self.axes_manager.navigation_dimension == 1: imf.yaxis = self.axes_manager.navigation_axes[0] imf.xaxis = self.axes_manager.signal_axes[0] elif self.axes_manager.navigation_dimension >= 2: imf.yaxis = self.axes_manager.navigation_axes[1] imf.xaxis = self.axes_manager.navigation_axes[0] if self.axes_manager.navigation_dimension > 2: navigation_sliders(self.axes_manager.navigation_axes, title=self.signal_title + " navigation sliders") for axis in self.axes_manager.navigation_axes[2:]: axis.connect(imf.update) imf.title = self.signal_title + ' Navigator' imf.plot() self.pointer.add_axes(imf.ax) self.navigator_plot = imf
def add_right_pointer(self): if self.signal_plot.right_axes_manager is None: self.signal_plot.right_axes_manager = \ copy.deepcopy(self.axes_manager) if self.right_pointer is None: pointer = self.assign_pointer() self.right_pointer = pointer(self.signal_plot.right_axes_manager) self.right_pointer.size = self.pointer.size self.right_pointer.color = 'blue' self.right_pointer.connect_navigate() self.right_pointer.set_mpl_ax(self.navigator_plot.ax) if self.right_pointer is not None: for axis in self.axes_manager.navigation_axes[self. _pointer_nav_dim:]: self.signal_plot.right_axes_manager._axes[ axis.index_in_array] = axis rl = spectrum.SpectrumLine() rl.autoscale = True rl.data_function = self.signal_data_function rl.set_line_properties(color=self.right_pointer.color, type='step') self.signal_plot.create_right_axis() self.signal_plot.add_line(rl, ax='right') rl.plot_indices = True rl.text_position = ( 1., 1.05, ) rl.plot() self.right_pointer_on = True
def add_right_pointer(self): if self.signal_plot.right_axes_manager is None: self.signal_plot.right_axes_manager = \ copy.deepcopy(self.axes_manager) if self.right_pointer is None: pointer = self.assign_pointer() self.right_pointer = pointer(self.signal_plot.right_axes_manager) self.right_pointer.size = self.pointer.size self.right_pointer.color = 'blue' self.right_pointer.add_axes(self.navigator_plot.ax) rl = spectrum.SpectrumLine() rl.autoscale = True rl.data_function = self.signal_data_function rl.set_line_properties(color=self.right_pointer.color, type='step') self.signal_plot.create_right_axis() self.signal_plot.add_line(rl, ax='right') rl.plot_indices = True rl.text_position = ( 1., 1.05, ) rl.plot() self.right_pointer_on = True