示例#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 test_colorbar_limits_not_default_values_on_surface_plot_with_monitor(self):
        ws = CreateSampleWorkspace(NumMonitors=1)
        fig = plt.figure()
        plot_surface([ws], fig=fig)
        ax = fig.get_axes()
        cmin, cmax = ax[0].collections[0].get_clim()

        # the colorbar limits default to +-0.1 when it can't find max and min of array
        self.assertNotEqual(cmax, 0.1)
        self.assertNotEqual(cmin, -0.1)
示例#3
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)
示例#4
0
 def test_is_colorbar(self):
     """Verify the functionality of _is_colorbar, which determines whether a set of axes is a colorbar."""
     ws = CreateSampleWorkspace()
     fig = plt.figure()
     fig = functions.plot_surface([ws], fig=fig)
     axes = fig.get_axes()
     # First set of axes is the surface plot
     self.assertFalse(WorkbenchNavigationToolbar._is_colorbar(axes[0]))
     # Second set of axes is the colorbar
     self.assertTrue(WorkbenchNavigationToolbar._is_colorbar(axes[1]))