Skip to content

Commit b283da7

Browse files
authored
Merge pull request #12423 from anntzer/svg-cleanup
Minor simplifications to backend_svg.
2 parents a054ee1 + ce0519a commit b283da7

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from collections import OrderedDict
2-
32
import base64
43
import gzip
54
import hashlib
@@ -155,7 +154,7 @@ def start(self, tag, attrib={}, **extra):
155154
if not v == '':
156155
k = escape_cdata(k)
157156
v = escape_attrib(v)
158-
self.__write(" %s=\"%s\"" % (k, v))
157+
self.__write(' %s="%s"' % (k, v))
159158
self.__open = 1
160159
return len(self.__tags)-1
161160

@@ -1005,9 +1004,8 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10051004

10061005
glyph_info, glyph_map_new, rects = _glyphs
10071006

1008-
# we store the character glyphs w/o flipping. Instead, the
1009-
# coordinate will be flipped when this characters are
1010-
# used.
1007+
# We store the character glyphs w/o flipping. Instead, the
1008+
# coordinate will be flipped when these characters are used.
10111009
if glyph_map_new:
10121010
writer.start('defs')
10131011
for char_id, glyph_path in glyph_map_new.items():
@@ -1161,14 +1159,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
11611159
for style, chars in spans.items():
11621160
chars.sort()
11631161

1164-
same_y = True
1165-
if len(chars) > 1:
1166-
last_y = chars[0][1]
1167-
for i in range(1, len(chars)):
1168-
if chars[i][1] != last_y:
1169-
same_y = False
1170-
break
1171-
if same_y:
1162+
if len({y for x, y, t in chars}) == 1: # Are all y's the same?
11721163
ys = str(chars[0][1])
11731164
else:
11741165
ys = ' '.join(str(c[1]) for c in chars)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy