Skip to content

Commit f435941

Browse files
committed
API: do not truncate the total size of svg element to integers
closes #9815
1 parent 2fd479a commit f435941

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Do not truncate svg sizes to nearest point
2+
------------------------------------------
3+
4+
There is no reason to size the SVG out put in integer points, change
5+
to out putting floats for the *height*, *width*, and *viewBox* attributes
6+
of the *svg* element.

lib/matplotlib/backends/backend_svg.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,14 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72):
285285

286286
RendererBase.__init__(self)
287287
self._glyph_map = dict()
288-
288+
str_height = short_float_fmt(height)
289+
str_width = short_float_fmt(width)
289290
svgwriter.write(svgProlog)
290291
self._start_id = self.writer.start(
291292
'svg',
292-
width='%ipt' % width, height='%ipt' % height,
293-
viewBox='0 0 %i %i' % (width, height),
293+
width='%spt' % str_width,
294+
height='%spt' % str_height,
295+
viewBox='0 0 %s %s' % (str_width, str_height),
294296
xmlns="http://www.w3.org/2000/svg",
295297
version="1.1",
296298
attrib={'xmlns:xlink': "http://www.w3.org/1999/xlink"})

0 commit comments

Comments
 (0)