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

Skip to content

Commit 006f6ad

Browse files
klausmdboom
klaus
authored andcommitted
OrderedDict instead of sorting
1 parent e75b44a commit 006f6ad

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from matplotlib.externals.six import unichr
77

88
import os, base64, tempfile, gzip, io, sys, codecs, re
9+
from collections import OrderedDict
910

1011
import numpy as np
1112

@@ -263,15 +264,15 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72):
263264
assert basename is not None
264265
self.basename = basename
265266
self._imaged = {}
266-
self._clipd = {}
267+
self._clipd = OrderedDict()
267268
self._char_defs = {}
268269
self._markers = {}
269270
self._path_collection_id = 0
270271
self._imaged = {}
271-
self._hatchd = {}
272+
self._hatchd = OrderedDict()
272273
self._has_gouraud = False
273274
self._n_gradients = 0
274-
self._fonts = {}
275+
self._fonts = OrderedDict()
275276
self.mathtext_parser = MathTextParser('SVG')
276277

277278
RendererBase.__init__(self)
@@ -1087,7 +1088,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10871088

10881089
# Sort the characters by font, and output one tspan for
10891090
# each
1090-
spans = {}
1091+
spans = OrderedDict()
10911092
for font, fontsize, thetext, new_x, new_y, metrics in svg_glyphs:
10921093
style = generate_css({
10931094
'font-size': six.text_type(fontsize) + 'px',
@@ -1103,7 +1104,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
11031104
fontset = self._fonts.setdefault(font.fname, set())
11041105
fontset.add(thetext)
11051106

1106-
for style, chars in list(six.iteritems(spans)):
1107+
for style, chars in six.iteritems(spans):
11071108
chars.sort()
11081109

11091110
same_y = True

lib/matplotlib/textpath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from matplotlib.font_manager import FontProperties, get_font
2121
from matplotlib.transforms import Affine2D
2222
from matplotlib.externals.six.moves.urllib.parse import quote as urllib_quote
23+
from collections import OrderedDict
2324

2425

2526
class TextToPath(object):
@@ -183,7 +184,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
183184
glyph_map = dict()
184185

185186
if return_new_glyphs_only:
186-
glyph_map_new = dict()
187+
glyph_map_new = OrderedDict()
187188
else:
188189
glyph_map_new = glyph_map
189190

0 commit comments

Comments
 (0)