Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee14544

Browse filesBrowse files
committed
Format floats in a Python2/3 compatible way
1 parent a678b61 commit ee14544
Copy full SHA for ee14544

File tree

Expand file treeCollapse file tree

1 file changed

+10
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-10
lines changed

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def generate_transform(transform_list=[]):
232232
if type == 'matrix' and isinstance(value, Affine2DBase):
233233
value = value.to_values()
234234

235-
output.write('%s(%s)' % (type, ' '.join(str(x) for x in value)))
235+
output.write('%s(%s)' % (type, ' '.join('%f' % x for x in value)))
236236
return output.getvalue()
237237
return ''
238238

@@ -401,18 +401,18 @@ def _get_style_dict(self, gc, rgbFace):
401401
if gc.get_hatch() is not None:
402402
attrib['fill'] = "url(#%s)" % self._get_hatch(gc, rgbFace)
403403
if rgbFace is not None and len(rgbFace) == 4 and rgbFace[3] != 1.0 and not forced_alpha:
404-
attrib['fill-opacity'] = str(rgbFace[3])
404+
attrib['fill-opacity'] = "%f" % rgbFace[3]
405405
else:
406406
if rgbFace is None:
407407
attrib['fill'] = 'none'
408408
else:
409409
if tuple(rgbFace[:3]) != (0, 0, 0):
410410
attrib['fill'] = rgb2hex(rgbFace)
411411
if len(rgbFace) == 4 and rgbFace[3] != 1.0 and not forced_alpha:
412-
attrib['fill-opacity'] = str(rgbFace[3])
412+
attrib['fill-opacity'] = "%f" % rgbFace[3]
413413

414414
if forced_alpha and gc.get_alpha() != 1.0:
415-
attrib['opacity'] = str(gc.get_alpha())
415+
attrib['opacity'] = "%f" % gc.get_alpha()
416416

417417
offset, seq = gc.get_dashes()
418418
if seq is not None:
@@ -424,9 +424,9 @@ def _get_style_dict(self, gc, rgbFace):
424424
rgb = gc.get_rgb()
425425
attrib['stroke'] = rgb2hex(rgb)
426426
if not forced_alpha and rgb[3] != 1.0:
427-
attrib['stroke-opacity'] = str(rgb[3])
427+
attrib['stroke-opacity'] = "%f" % rgb[3]
428428
if linewidth != 1.0:
429-
attrib['stroke-width'] = str(linewidth)
429+
attrib['stroke-width'] = "%f" % linewidth
430430
if gc.get_joinstyle() != 'round':
431431
attrib['stroke-linejoin'] = gc.get_joinstyle()
432432
if gc.get_capstyle() != 'butt':
@@ -754,7 +754,7 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
754754
'use',
755755
attrib={'xlink:href': href,
756756
'fill': rgb2hex(avg_color),
757-
'fill-opacity': str(avg_color[-1])})
757+
'fill-opacity': "%f" % avg_color[-1]})
758758
for i in range(3):
759759
writer.element(
760760
'use',
@@ -840,7 +840,7 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
840840

841841
alpha = gc.get_alpha()
842842
if alpha != 1.0:
843-
attrib['opacity'] = str(alpha)
843+
attrib['opacity'] = "%f" % alpha
844844

845845
attrib['id'] = oid
846846

@@ -1046,8 +1046,8 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10461046
'center': 'middle'}
10471047
style['text-anchor'] = ha_mpl_to_svg[mtext.get_ha()]
10481048

1049-
attrib['x'] = str(ax)
1050-
attrib['y'] = str(ay)
1049+
attrib['x'] = "%f" % ax
1050+
attrib['y'] = "%f" % ay
10511051
attrib['style'] = generate_css(style)
10521052
attrib['transform'] = "rotate(%f, %f, %f)" % (-angle, ax, ay)
10531053
writer.element('text', s, attrib=attrib)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.