Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
API: do not truncate the total size of svg element to integers
closes #9815
  • Loading branch information
tacaswell committed Nov 19, 2017
commit f435941406e95bb2fa1ba3bcf3b579457e5839fa
6 changes: 6 additions & 0 deletions doc/api/api_changes/2017-11-19_svg_size.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Do not truncate svg sizes to nearest point
------------------------------------------

There is no reason to size the SVG out put in integer points, change
to out putting floats for the *height*, *width*, and *viewBox* attributes
of the *svg* element.
8 changes: 5 additions & 3 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72):

RendererBase.__init__(self)
self._glyph_map = dict()

str_height = short_float_fmt(height)
str_width = short_float_fmt(width)
svgwriter.write(svgProlog)
self._start_id = self.writer.start(
'svg',
width='%ipt' % width, height='%ipt' % height,
viewBox='0 0 %i %i' % (width, height),
width='%spt' % str_width,
height='%spt' % str_height,
viewBox='0 0 %s %s' % (str_width, str_height),
xmlns="http://www.w3.org/2000/svg",
version="1.1",
attrib={'xmlns:xlink': "http://www.w3.org/1999/xlink"})
Expand Down