8000 Backport qt editor improvements by anntzer · Pull Request #6717 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport qt editor improvements #6717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort default labels numerically in Qt editor.
  • Loading branch information
anntzer committed Jul 10, 2016
commit 6d9b4a5ae7685ac244f799f9391c0403227d63e9
13 changes: 11 additions & 2 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import six

import os.path as osp
import re

import matplotlib.backends.qt_editor.formlayout as formlayout
from matplotlib.backends.qt_compat import QtGui
Expand Down Expand Up @@ -67,6 +68,14 @@ def figure_edit(axes, parent=None):
xunits = axes.xaxis.get_units()
yunits = axes.yaxis.get_units()

# Sorting for default labels (_lineXXX, _imageXXX).
def cmp_key(label):
match = re.match(r"(_line|_image)(\d+)", label)
if match:
return match.group(1), int(match.group(2))
else:
return label, 0

# Get / Curves
linedict = {}
for line in axes.get_lines():
Expand Down Expand Up @@ -100,7 +109,7 @@ def prepare_data(d, init):
sorted(short2name.items(),
key=lambda short_and_name: short_and_name[1]))

curvelabels = sorted(linedict.keys())
curvelabels = sorted(linedict, key=cmp_key)
for label in curvelabels:
line = linedict[label]
color = rgb2hex(colorConverter.to_rgb(line.get_color()))
Expand Down Expand Up @@ -131,7 +140,7 @@ def prepare_data(d, init):
if label == '_nolegend_':
continue
imagedict[label] = image
imagelabels = sorted(imagedict)
imagelabels = sorted(imagedict, key=cmp_key)
images = []
cmaps = [(cmap, name) for name, cmap in sorted(cm.cmap_d.items())]
for label in imagelabels:
Expand Down
0