From dda982b3b5dee0bcc3f9cd6694cd723430ab2541 Mon Sep 17 00:00:00 2001 From: Conor Finn <conor.finn@stfc.ac.uk> Date: Tue, 24 Mar 2020 12:17:29 +0000 Subject: [PATCH] RE #28227 Correct colorbar when normalisation changes The colour bar was reset to -0.1 and +0.1 when the normalistion was changed. This reperforms the setting of the colour bar to the max and min values in the workspace. --- .../workbench/workbench/plotting/figureinteraction.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qt/applications/workbench/workbench/plotting/figureinteraction.py b/qt/applications/workbench/workbench/plotting/figureinteraction.py index a23811d34f0..e04c78b580a 100644 --- a/qt/applications/workbench/workbench/plotting/figureinteraction.py +++ b/qt/applications/workbench/workbench/plotting/figureinteraction.py @@ -12,6 +12,7 @@ Defines interaction behaviour for plotting. from __future__ import (absolute_import, unicode_literals) # std imports +import numpy as np from collections import OrderedDict from copy import copy from functools import partial @@ -704,6 +705,12 @@ class FigureInteraction(object): if ax.lines: # Relim causes issues with colour plots, which have no lines. ax.relim() + if ax.images: # Colour bar limits are wrong if workspace is ragged. Set them manually. + colorbar_min = np.nanmin(ax.images[-1].get_array()) + colorbar_max = np.nanmax(ax.images[-1].get_array()) + for image in ax.images: + image.set_clim(colorbar_min, colorbar_max) + ax.autoscale() datafunctions.set_initial_dimensions(ax) -- GitLab