Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit febbcf6

Browse files
authored
Merge pull request #22214 from meeseeksmachine/auto-backport-of-pr-22208-on-v3.5.x
Backport PR #22208 on branch v3.5.x (Stop sorting artists in Figure Options dialog)
2 parents 7b50116 + d603bc8 commit febbcf6

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
"""Module that provides a GUI-based editor for Matplotlib's figure options."""
77

8-
import re
9-
108
from matplotlib import cbook, cm, colors as mcolors, markers, image as mimage
119
from matplotlib.backends.qt_compat import QtGui
1210
from matplotlib.backends.qt_editor import _formlayout
@@ -65,18 +63,6 @@ def convert_limits(lim, converter):
6563
xunits = axes.xaxis.get_units()
6664
yunits = axes.yaxis.get_units()
6765

68-
# Sorting for default labels (_lineXXX, _imageXXX).
69-
def cmp_key(label):
70-
"""
71-
Label should be a tuple consisting of the string label,
72-
and the object being sorted by label.
73-
"""
74-
match = re.match(r"(_line|_image)(\d+)", label[0])
75-
if match:
76-
return match.group(1), int(match.group(2))
77-
else:
78-
return label[0], 0
79-
8066
# Get / Curves
8167
labeled_lines = []
8268
for line in axes.get_lines():
@@ -113,7 +99,7 @@ def prepare_data(d, init):
11399
sorted(short2name.items(),
114100
key=lambda short_and_name: short_and_name[1]))
115101

116-
for label, line in sorted(labeled_lines, key=cmp_key):
102+
for label, line in labeled_lines:
117103
color = mcolors.to_hex(
118104
mcolors.to_rgba(line.get_color(), line.get_alpha()),
119105
keep_alpha=True)
@@ -150,7 +136,7 @@ def prepare_data(d, init):
150136
labeled_mappables.append((label, mappable))
151137
mappables = []
152138
cmaps = [(cmap, name) for name, cmap in sorted(cm._cmap_registry.items())]
153-
for label, mappable in sorted(labeled_mappables, key=cmp_key):
139+
for label, mappable in labeled_mappables:
154140
cmap = mappable.get_cmap()
155141
if cmap not in cm._cmap_registry.values():
156142
cmaps = [(cmap, cmap.name), *cmaps]

0 commit comments

Comments
 (0)