def remove_selected_curves(self): """ Remove selected curves from figure and curves list. If there are no curves left on the axes remove that axes from the axes combo box """ ax = self.get_selected_ax() if ax.legend_: self.legend_props = LegendProperties.from_legend(ax.legend_) # Remove curves from ax and remove from curve names dictionary curves_to_remove_names = self.view.get_selected_curves_names() for name in curves_to_remove_names: remove_curve_from_ax(self.curve_names_dict[name]) self.curve_names_dict.pop(name) self.set_apply_to_all_buttons_enabled() ax = self.get_selected_ax() # Update the legend and redraw FigureErrorsManager.update_limits_and_legend(ax, self.legend_props) ax.figure.canvas.draw() # Remove the curve from the curve selection list if self.remove_selected_curve_list_entry(): return self.update_view()
def remove_selected_curve(self): """ Remove selected curve from figure and combobox. If there are no curves left on the axes remove that axes from the axes combo box """ ax = self.get_selected_ax() if ax.legend_: self.legend_props = LegendProperties.from_legend(ax.legend_) waterfall = False if isinstance(ax, MantidAxes): waterfall = ax.is_waterfall() if waterfall: # Waterfall plots are reset so they can be reconverted after the curve is removed. x, y = ax.waterfall_x_offset, ax.waterfall_y_offset ax.update_waterfall(0, 0) # If the curves have a fill, the one which corresponds to the curve being removed also needs to be removed. current_curve_index = self.view.select_curve_combo_box.currentIndex( ) i = 0 for collection in ax.collections: if isinstance(collection, PolyCollection): if current_curve_index == i: ax.collections.remove(collection) break i = i + 1 # Remove curve from ax and remove from curve names dictionary remove_curve_from_ax(self.get_selected_curve()) self.curve_names_dict.pop(self.view.get_selected_curve_name()) self.set_apply_to_all_buttons_enabled() # If there is now only one curve on a waterfall plot, the plot becomes non-waterfall. if waterfall: ax.update_waterfall(x, y) if len(ax.get_lines()) <= 1: ax.set_waterfall(False) ax = self.get_selected_ax() # Update the legend and redraw FigureErrorsManager.update_limits_and_legend(ax, self.legend_props) ax.figure.canvas.draw() # Remove the curve from the curve selection combo box if self.remove_selected_curve_combo_box_entry(): return self.update_view()
def apply_properties(self): """Take properties from views and set them on the selected curve""" ax = self.get_selected_ax() if ax.legend_: self.legend_props = LegendProperties.from_legend(ax.legend_) view_props = self.get_view_properties() if view_props == self.current_view_properties: return plot_kwargs = view_props.get_plot_kwargs() # Re-plot curve self._replot_current_curve(plot_kwargs) curve = self.get_current_curve() # Set the curve's new name in the names dict and combo box self.set_new_curve_name_in_dict_and_list(curve, view_props.label) FigureErrorsManager.toggle_errors(curve, view_props) self.current_view_properties = view_props FigureErrorsManager.update_limits_and_legend(ax, self.legend_props)