def fitting_done_slot(self, name): """ This is called after Fit finishes to update the fit curves. :param name: The name of Fit's output workspace. """ from mantidqt.plotting.functions import plot ws = mtd[name] # Keep local copy of the original lines original_lines = self.get_lines() self.clear_fit_result_lines() plot([ws], wksp_indices=[1, 2], fig=self.canvas.figure, overplot=True) name += ':' for lin in self.get_lines(): if lin.get_label().startswith(name): self.fit_result_lines.append(lin) # Add properties back to the lines new_lines = self.get_lines() for new_line, old_line in zip(new_lines, original_lines): new_line.update_from(old_line) # Now update the legend to make sure it changes to the old properties self.get_axes().legend().draggable()
def test_workspace_tracked_when_plotting_over_scripted_fig(self): fig = plt.figure() plt.plot([0, 1], [0, 1]) ws = self._test_ws plot([ws], wksp_indices=[1], fig=fig, overplot=True) ax = plt.gca() self.assertIn(ws.name(), ax.tracked_workspaces)
def plot_guess(self): """ Plot the guess curve. """ from mantidqt.plotting.functions import plot fun = self.getFittingFunction() ws_name = self.workspaceName() if fun == '' or ws_name == '': return ws_index = self.workspaceIndex() out_ws_name = '{}_guess'.format(ws_name) alg = AlgorithmManager.createUnmanaged('EvaluateFunction') alg.setChild(True) alg.initialize() alg.setProperty('Function', fun) alg.setProperty('InputWorkspace', ws_name) alg.setProperty('WorkspaceIndex', ws_index) alg.setProperty('OutputWorkspace', out_ws_name) alg.execute() out_ws = alg.getProperty('OutputWorkspace').value plot([out_ws], wksp_indices=[1], fig=self.canvas.figure, overplot=True, plot_kwargs={'label': out_ws_name}) for lin in self.get_lines(): if lin.get_label().startswith(out_ws_name): self.guess_line = lin self.setTextPlotGuess('Remove Guess') self.canvas.draw()
def plot_graph(workspace): if IN_MANTIDPLOT: return mantidplot.plotSpectrum(workspace, 0) elif not PYQT4: if not isinstance(workspace, list): workspace = [workspace] plot(workspace, wksp_indices=[0])
def test_workspace_can_be_plotted_on_top_of_scripted_plots(self): fig = plt.figure() plt.plot([0, 1], [0, 1]) ws = self._test_ws plot([ws], wksp_indices=[1], fig=fig, overplot=True) ax = plt.gca() self.assertEqual(len(ax.lines), 2)
def test_different_line_colors_when_plotting_over_scripted_fig(self): fig = plt.figure() plt.plot([0, 1], [0, 1]) ws = self._test_ws plot([ws], wksp_indices=[1], fig=fig, overplot=True) ax = plt.gca() line_colors = [line.get_color() for line in ax.get_lines()] self.assertNotEqual(line_colors[0], line_colors[1])
def test_title_preserved_when_workspace_plotted_on_scripted_plot(self): fig = plt.figure() plt.plot([0, 1], [0, 1]) plt.title("My Title") ws = self._test_ws plot([ws], wksp_indices=[1], fig=fig, overplot=True) ax = plt.gca() self.assertEqual("My Title", ax.get_title())
def start_emu(self): res1 = Load(r'emu00006473.nxs', OutputWorkspace='ws1') Load(r'emu00006475.nxs', OutputWorkspace='ws2') plot([res1[0]], [3, 5, 7]) manager = GlobalFigureManager.get_active() self.w = manager.window trigger_action(find_action_with_text(self.w, 'Fit')) yield 0.1 self.fit_browser = manager.fit_browser
def fitting_done(self, name): from mantidqt.plotting.functions import plot name += '_Workspace' ws = mtd[name] self.clear_fit_result_lines() plot([ws], wksp_indices=[1, 2], fig=self.canvas.figure, overplot=True) name += ':' for lin in self.get_lines(): if lin.get_label().startswith(name): self.fit_result_lines.append(lin)
def test_overplotting_onto_waterfall_plot_maintains_waterfall(self): fig = plt.figure() ws = self._test_ws plot([ws], wksp_indices=[0,1], fig=fig, waterfall=True) # Overplot one of the same lines. plot([ws], wksp_indices=[0], fig=fig, overplot=True) ax = plt.gca() # Check that the lines which would be the same in a non-waterfall plot are different. self.assertNotEqual(ax.get_lines()[0].get_xdata()[0], ax.get_lines()[2].get_xdata()[0]) self.assertNotEqual(ax.get_lines()[0].get_ydata()[0], ax.get_lines()[2].get_ydata()[0])
def start(self): if 'ws' not in mtd: ws = Load(r'irs26176_graphite002_conv_1LFixF_s0_to_9_Result.nxs', OutputWorkspace='ws') else: ws = mtd['ws'] plot([ws], [1]) manager = GlobalFigureManager.get_active() self.w = manager.window trigger_action(find_action_with_text(self.w, 'Fit')) yield 0.1 self.fit_browser = manager.fit_browser
def _plot_quartiles_matplotlib(output_workspaces, sample_scatter): title = '{}_beam_centre_finder'.format(sample_scatter) ax_properties = {'xscale': 'log', 'yscale': 'log'} plot_kwargs = {"scalex": True, "scaley": True} if not isinstance(output_workspaces, list): output_workspaces = [output_workspaces] plot(output_workspaces, wksp_indices=[0], ax_properties=ax_properties, overplot=True, plot_kwargs=plot_kwargs, window_title=title)
def _plot_quartiles_matplotlib(self, output_workspaces, sample_scatter): title = '{}_beam_centre_finder'.format(sample_scatter) ax_properties = {'xscale': 'log', 'yscale': 'log'} plot_kwargs = {"scalex": True, "scaley": True} if not isinstance(output_workspaces, list): output_workspaces = [output_workspaces] if not WITHOUT_GUI: plot(output_workspaces, wksp_indices=[0], ax_properties=ax_properties, overplot=True, plot_kwargs=plot_kwargs, window_title=title)
def test_plot_from_names_within_existing_figure(self, get_spectra_selection_mock): # make existing plot fig = plot([self._test_ws], wksp_indices=[0]) self._do_plot_from_names_test(get_spectra_selection_mock, expected_labels=["spec 1", "spec 2"], wksp_indices=[1], errors=False, overplot=False, target_fig=fig)
def test_plot_from_names_produces_overplot_for_valid_name(self, get_spectra_selection_mock): # make first plot plot([self._test_ws], wksp_indices=[0]) self._do_plot_from_names_test(get_spectra_selection_mock, expected_labels=["spec 1", "spec 2"], wksp_indices=[1], errors=False, overplot=True)