diff --git a/Framework/PythonInterface/mantid/plots/mantidaxes.py b/Framework/PythonInterface/mantid/plots/mantidaxes.py index a0300b7205000cd410f37444deaed190afc9aac8..e0a8e8632dd3209798819399d2e42afcdb627f1c 100644 --- a/Framework/PythonInterface/mantid/plots/mantidaxes.py +++ b/Framework/PythonInterface/mantid/plots/mantidaxes.py @@ -1128,6 +1128,13 @@ class MantidAxes3D(Axes3D): name = 'mantid3d' + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Remove the connection for when you click on the plot as this is dealt with in figureinteraction.py to stop + # it interfering with double-clicking on the axes. + self.figure.canvas.mpl_disconnect(self._cids[1]) + def plot(self, *args, **kwargs): """ If the **mantid3d** projection is chosen, it can be diff --git a/docs/source/release/v5.1.0/mantidworkbench.rst b/docs/source/release/v5.1.0/mantidworkbench.rst index 8107b1d6ff443e29d2cf3dfa76844468d4f6fabe..44ae332c90cc5ec753bb397c653896ae1c0ad2d4 100644 --- a/docs/source/release/v5.1.0/mantidworkbench.rst +++ b/docs/source/release/v5.1.0/mantidworkbench.rst @@ -17,6 +17,8 @@ Improvements This is similar to what Mantidplot does, and should result in the script stopping much sooner. - Fixed an issue where some scripts were running slower if a plot was open at the same time. +- On 3D plots you can now double-click on the z-axis to change its limits or label. + Bugfixes ######## diff --git a/qt/applications/workbench/workbench/plotting/figureinteraction.py b/qt/applications/workbench/workbench/plotting/figureinteraction.py index f54cdce9b624002606d9319020049da9fa2f6f4e..05979fb55dba3a7663c9321d153cfaa6bfc6b389 100644 --- a/qt/applications/workbench/workbench/plotting/figureinteraction.py +++ b/qt/applications/workbench/workbench/plotting/figureinteraction.py @@ -20,6 +20,7 @@ from qtpy.QtGui import QCursor from qtpy.QtWidgets import QActionGroup, QMenu, QApplication from matplotlib.colors import LogNorm, Normalize from matplotlib.collections import Collection +from mpl_toolkits.mplot3d.axes3d import Axes3D # third party imports from mantid.api import AnalysisDataService as ads @@ -31,7 +32,7 @@ from mantidqt.widgets.plotconfigdialog.curvestabwidget import curve_has_errors, from workbench.plotting.figureerrorsmanager import FigureErrorsManager from workbench.plotting.propertiesdialog import (LabelEditor, XAxisEditor, YAxisEditor, SingleMarkerEditor, GlobalMarkerEditor, - ColorbarAxisEditor) + ColorbarAxisEditor, ZAxisEditor) from workbench.plotting.style import VALID_LINE_STYLE, VALID_COLORS from workbench.plotting.toolbar import ToolbarStateManager @@ -152,6 +153,8 @@ class FigureInteraction(object): self.canvas.toolbar.press_pan(event) finally: event.button = 3 + elif isinstance(event.inaxes, Axes3D): + event.inaxes._button_press(event) def on_mouse_button_release(self, event): """ Stop moving the markers when the mouse button is released """ @@ -227,6 +230,12 @@ class FigureInteraction(object): move_and_show(YAxisEditor(canvas, ax)) else: move_and_show(ColorbarAxisEditor(canvas, ax)) + if hasattr(ax, 'zaxis'): + if ax.zaxis.label.contains(event)[0]: + move_and_show(LabelEditor(canvas, ax.zaxis.label)) + elif (ax.zaxis.contains(event)[0] + or any(tick.contains(event)[0] for tick in ax.get_zticklabels())): + move_and_show(ZAxisEditor(canvas, ax)) def _show_markers_menu(self, markers, event): """ @@ -765,5 +774,6 @@ class FigureInteraction(object): for ax in self.canvas.figure.get_axes(): images = ax.get_images() + [col for col in ax.collections if isinstance(col, Collection)] for image in images: - datafunctions.update_colorbar_scale(self.canvas.figure, image, scale_type, image.norm.vmin, image.norm.vmax) + datafunctions.update_colorbar_scale(self.canvas.figure, image, scale_type, image.norm.vmin, + image.norm.vmax) self.canvas.draw_idle() diff --git a/qt/applications/workbench/workbench/plotting/propertiesdialog.py b/qt/applications/workbench/workbench/plotting/propertiesdialog.py index ba10e60d7be6d408c11ffd2b78d31a8520d1d12b..7698d968334e89073d4409c7f9cc923b12ccd9ed 100644 --- a/qt/applications/workbench/workbench/plotting/propertiesdialog.py +++ b/qt/applications/workbench/workbench/plotting/propertiesdialog.py @@ -189,6 +189,13 @@ class YAxisEditor(AxisEditor): self.create_model() +class ZAxisEditor(AxisEditor): + + def __init__(self, canvas, axes): + super(ZAxisEditor, self).__init__(canvas, axes, 'z') + self.create_model() + + class ColorbarAxisEditor(AxisEditor): def __init__(self, canvas, axes):