FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Sort default labels numerically in Qt editor. by anntzer · Pull Request #6366 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Sort default labels numerically in Qt editor.
  • Loading branch information
anntzer committed May 5, 2016
commit ad4830ccceff073e0cd332df20d8158d10c8fcdc
13 changes: 11 additions & 2 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from matplotlib.externals 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

Back | FazBrowse Home | New Git URL