示例#1
0
    def _do_plot_1d_md(self, names, errors, overplot):
        """
        Plot 1D IMDHistoWorlspaces

        :param names: list of workspace names
        :param errors: boolean.  if true, the error bar will be plotted
        :param overplot: boolean.  If true, then add these plots to the current figure if one exists
                                   and it is a compatible figure
        :return:
        """
        try:
            plot_md_ws_from_names(names, errors, overplot)
        except RuntimeError as re:
            logger.error(str(re))
示例#2
0
    def _do_plot_md_from_names_test(self, expected_labels, errors, overplot,
                                    target_fig):
        """
        Do plot_md_ws_from_names test (in general)

        :param expected_labels: list of strings as expected labels of a plot (i.e., workspace name)
        :param errors:
        :param overplot:
        :param target_fig:
        :return:
        """
        ws_name = 'test_plot_md_from_names_ws'
        AnalysisDataService.Instance().addOrReplace(ws_name, self._test_md_ws)

        # call method to test
        test_fig = plot_md_ws_from_names([ws_name], errors, overplot,
                                         target_fig)

        # Verification: with target figure, new plot will be plotted on the same one
        if target_fig is not None:
            self.assertEqual(target_fig, test_fig)

        # Check lines plotted
        plotted_lines = test_fig.gca().get_legend().get_lines()

        # number of plotted lines must be equal to expected values
        self.assertEqual(len(expected_labels), len(plotted_lines))
        # check legend labels
        for label_part, line in zip(expected_labels, plotted_lines):
            if label_part is not None:
                self.assertTrue(label_part in line.get_label())