예제 #1
0
    def _plot_on_here(self, names, ax):
        """
        Assume the list of strings refer to workspace names and they are to be plotted
        on this figure. If the current figure contains an image plot then
        a new image plot will replace the current image. If the current figure
        contains a line plot then the user will be asked what should be plotted and this
        will overplot onto the figure. If the first line of the plot
        :param names: A list of workspace names
        :param ax: The matplotlib axes object to overplot onto
        """
        if len(names) == 0:
            return
        # local import to avoid circular import with FigureManager
        from mantidqt.plotting.functions import pcolormesh, plot_from_names, plot_surface, plot_wireframe, plot_contour

        fig = self._canvas.figure
        fig_type = figure_type(fig, ax)
        if fig_type == FigureType.Image:
            pcolormesh(names, fig=fig)
        elif fig_type == FigureType.Surface:
            plot_surface(names, fig=fig)
        elif fig_type == FigureType.Wireframe:
            plot_wireframe(names, fig=fig)
        elif fig_type == FigureType.Contour:
            plot_contour(names, fig=fig)
        else:
            plot_from_names(names, errors=(fig_type == FigureType.Errorbar),
                            overplot=ax, fig=fig)
예제 #2
0
def plot(plot_type: SpectraSelection, plot_index: int, axis_name: str, log_name: str, custom_log_values: List[float],
         workspaces: List[Workspace]) -> None:
    if len(workspaces) > 0:
        matrix_ws = _create_workspace_for_group_plot(plot_type, workspaces, plot_index, log_name, custom_log_values)

        workspace_names = [ws.name() for ws in workspaces]
        title = _construct_title(workspace_names, plot_index)

        if plot_type == SpectraSelection.Surface:
            fig = plot_surface([matrix_ws])
            ax = fig.get_axes()[0]

            ax.set_title("Surface" + title)
            ax.set_ylabel(axis_name)

            fig.canvas.set_window_title("Surface" + title)
            fig.show()
        elif plot_type == SpectraSelection.Contour:
            fig = plot_contour([matrix_ws])
            ax = fig.get_axes()[0]

            ax.set_ylabel(axis_name)
            ax.set_title("Contour" + title)

            fig.canvas.set_window_title("Contour" + title)
예제 #3
0
    def test_toggle_normalisation_on_contour_plot_maintains_contour_line_colour(self):
        from mantid.plots.legend import convert_color_to_hex
        ws = CreateWorkspace(DataX=[1, 2, 3, 4, 2, 4, 6, 8], DataY=[2] * 8, NSpec=2, OutputWorkspace="test_ws")
        fig = plot_contour([ws])

        for col in fig.get_axes()[0].collections:
            col.set_color("#ff9900")

        mock_canvas = MagicMock(figure=fig)
        fig_manager_mock = MagicMock(canvas=mock_canvas)
        fig_interactor = FigureInteraction(fig_manager_mock)
        fig_interactor._toggle_normalization(fig.axes[0])

        self.assertTrue(all(convert_color_to_hex(col.get_color()[0]) == "#ff9900"
                            for col in fig.get_axes()[0].collections))