|
13 | 13 | import six |
14 | 14 |
|
15 | 15 | import os.path as osp |
| 16 | +import re |
16 | 17 |
|
17 | 18 | import matplotlib.backends.qt_editor.formlayout as formlayout |
18 | 19 | from matplotlib.backends.qt_compat import QtGui |
@@ -67,6 +68,14 @@ def figure_edit(axes, parent=None): |
67 | 68 | xunits = axes.xaxis.get_units() |
68 | 69 | yunits = axes.yaxis.get_units() |
69 | 70 |
|
| 71 | + # Sorting for default labels (_lineXXX, _imageXXX). |
| 72 | + def cmp_key(label): |
| 73 | + match = re.match(r"(_line|_image)(\d+)", label) |
| 74 | + if match: |
| 75 | + return match.group(1), int(match.group(2)) |
| 76 | + else: |
| 77 | + return label, 0 |
| 78 | + |
70 | 79 | # Get / Curves |
71 | 80 | linedict = {} |
72 | 81 | for line in axes.get_lines(): |
@@ -100,7 +109,7 @@ def prepare_data(d, init): |
100 | 109 | sorted(short2name.items(), |
101 | 110 | key=lambda short_and_name: short_and_name[1])) |
102 | 111 |
|
103 | | - curvelabels = sorted(linedict.keys()) |
| 112 | + curvelabels = sorted(linedict, key=cmp_key) |
104 | 113 | for label in curvelabels: |
105 | 114 | line = linedict[label] |
106 | 115 | color = rgb2hex(colorConverter.to_rgb(line.get_color())) |
@@ -131,7 +140,7 @@ def prepare_data(d, init): |
131 | 140 | if label == '_nolegend_': |
132 | 141 | continue |
133 | 142 | imagedict[label] = image |
134 | | - imagelabels = sorted(imagedict) |
| 143 | + imagelabels = sorted(imagedict, key=cmp_key) |
135 | 144 | images = [] |
136 | 145 | cmaps = [(cmap, name) for name, cmap in sorted(cm.cmap_d.items())] |
137 | 146 | for label in imagelabels: |
|
0 commit comments