def test_plot_1d_md(self): """Test to plot 1D IMDHistoWorkspace """ fig = plt.figure() plt.plot([0, 1], [0, 1]) ws = self._test_md_ws plot_md_histo_ws([ws], fig=fig, overplot=True) ax = plt.gca() self.assertEqual( len(ax.lines), 2, msg=f'With overplot on an existing fig, there shall be 2 lines,' f'but not {len(ax.lines)} lines.')
def plot_md_ws_from_names(names, errors, overplot, fig=None): """ Given a list of names of 1-dimensional IMDHistoWorkspaces and plot :param names: A list of workspaces names :param errors: If true then error bars will be plotted on the points :param overplot: If true then the add to the current figure if one exists and it is a compatible figure :param fig: If not None then use this figure object to plot :return: The figure containing the plot or None if selection was cancelled """ # Get workspaces workspaces = AnalysisDataService.Instance().retrieveWorkspaces( names, unrollGroups=True) # Check input workspace type for ws in workspaces: if not isinstance(ws, IMDHistoWorkspace): raise RuntimeError( f'Workspace {str(ws)} is {type(ws)} but not an IMDHistoWorkspace' ) # Plot for various cases if len(workspaces) > 0: return plot_md_histo_ws(workspaces, errors=errors, overplot=overplot, fig=fig, ax_properties=None, window_title=None)