From 2f28508b2d9d1320192a8d960493ae256009ea40 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 28 Apr 2016 11:39:51 -0700 Subject: [PATCH] Allow setting image clims in Qt options editor. Currently, `(cmin, cmax)` is swapped if `cmin > cmax` because it's not easy to impose the constraint using formlayout. --- lib/matplotlib/backends/qt_editor/figureoptions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/qt_editor/figureoptions.py b/lib/matplotlib/backends/qt_editor/figureoptions.py index 6a485302f4e9..c044979dee96 100644 --- a/lib/matplotlib/backends/qt_editor/figureoptions.py +++ b/lib/matplotlib/backends/qt_editor/figureoptions.py @@ -139,10 +139,12 @@ def prepare_data(d, init): cmap = image.get_cmap() if cmap not in cm.cmap_d.values(): cmaps = [(cmap, cmap.name)] + cmaps + low, high = image.get_clim() imagedata = [ ('Label', label), - ('Colormap', [cmap.name] + cmaps) - ] + ('Colormap', [cmap.name] + cmaps), + ('Min. value', low), + ('Max. value', high)] images.append([imagedata, label, ""]) # Is there an image displayed? has_image = bool(images) @@ -199,9 +201,10 @@ def apply_callback(data): # Set / Images for index, image_settings in enumerate(images): image = imagedict[imagelabels[index]] - label, cmap = image_settings + label, cmap, low, high = image_settings image.set_label(label) image.set_cmap(cm.get_cmap(cmap)) + image.set_clim(*sorted([low, high])) # re-generate legend, if checkbox is checked if generate_legend: