From d603bc800502ba26036e0d2fea2efd5ccb4ed06a Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 12 Jan 2022 10:11:46 -0500 Subject: [PATCH] Backport PR #22208: Stop sorting artists in Figure Options dialog --- .../backends/qt_editor/figureoptions.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/matplotlib/backends/qt_editor/figureoptions.py b/lib/matplotlib/backends/qt_editor/figureoptions.py index 8b5295f1d7df..31e929c4a7c2 100644 --- a/lib/matplotlib/backends/qt_editor/figureoptions.py +++ b/lib/matplotlib/backends/qt_editor/figureoptions.py @@ -5,8 +5,6 @@ """Module that provides a GUI-based editor for Matplotlib's figure options.""" -import re - from matplotlib import cbook, cm, colors as mcolors, markers, image as mimage from matplotlib.backends.qt_compat import QtGui from matplotlib.backends.qt_editor import _formlayout @@ -65,18 +63,6 @@ def convert_limits(lim, converter): xunits = axes.xaxis.get_units() yunits = axes.yaxis.get_units() - # Sorting for default labels (_lineXXX, _imageXXX). - def cmp_key(label): - """ - Label should be a tuple consisting of the string label, - and the object being sorted by label. - """ - match = re.match(r"(_line|_image)(\d+)", label[0]) - if match: - return match.group(1), int(match.group(2)) - else: - return label[0], 0 - # Get / Curves labeled_lines = [] for line in axes.get_lines(): @@ -113,7 +99,7 @@ def prepare_data(d, init): sorted(short2name.items(), key=lambda short_and_name: short_and_name[1])) - for label, line in sorted(labeled_lines, key=cmp_key): + for label, line in labeled_lines: color = mcolors.to_hex( mcolors.to_rgba(line.get_color(), line.get_alpha()), keep_alpha=True) @@ -150,7 +136,7 @@ def prepare_data(d, init): labeled_mappables.append((label, mappable)) mappables = [] cmaps = [(cmap, name) for name, cmap in sorted(cm._cmap_registry.items())] - for label, mappable in sorted(labeled_mappables, key=cmp_key): + for label, mappable in labeled_mappables: cmap = mappable.get_cmap() if cmap not in cm._cmap_registry.values(): cmaps = [(cmap, cmap.name), *cmaps]