diff --git a/doc/api/api_changes/2017-11-19_svg_size.rst b/doc/api/api_changes/2017-11-19_svg_size.rst new file mode 100644 index 000000000000..9a9ef9ecd232 --- /dev/null +++ b/doc/api/api_changes/2017-11-19_svg_size.rst @@ -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. diff --git a/lib/matplotlib/backends/backend_svg.py b/lib/matplotlib/backends/backend_svg.py index f799973f932e..bf09351655a0 100644 --- a/lib/matplotlib/backends/backend_svg.py +++ b/lib/matplotlib/backends/backend_svg.py @@ -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"}) diff --git a/lib/matplotlib/tests/baseline_images/test_artist/hatching.svg b/lib/matplotlib/tests/baseline_images/test_artist/hatching.svg index 893ec54dda3d..ba93c768832c 100644 --- a/lib/matplotlib/tests/baseline_images/test_artist/hatching.svg +++ b/lib/matplotlib/tests/baseline_images/test_artist/hatching.svg @@ -2,7 +2,7 @@ - +