def switch_on_off(self, obj, trait_name, old, new): if not self.signal._plot.is_active(): return if new is True and old is False: self._line = DraggableVerticalLine(self.axes_manager) self._line.add_axes(self.signal._plot.signal_plot.ax) self._line.patch.set_linewidth(2) self._color_changed("black", "black") # There is not need to call draw because setting the # color calls it. elif new is False and old is True: self._line.close() self._line = None self.draw()