Circle Markers + vector graphics

Hi,

Is there any reason that circles are approximated by polygons when written out by vector graphics backends (i.e. SVG, PS)? Someone pointed this out to me, and having verified it, I found it surprising. I would think since at least SVG directly supports circles, they'd be used for output.

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

This has been fixed in mpl svn for Agg and PS and will be included in
the next release, but not yet for SVG. In the "transforms" branch,
all supported backends (including Agg, PS and SVG draw "true" circles,
and the plan is to merge these changes into the main trunk sometime
after the next release.

JDH

···

On Nov 14, 2007 1:53 PM, Ryan May <rmay@...553...> wrote:

Hi,

Is there any reason that circles are approximated by polygons when
written out by vector graphics backends (i.e. SVG, PS)? Someone pointed
this out to me, and having verified it, I found it surprising. I would
think since at least SVG directly supports circles, they'd be used for
output.

John Hunter wrote:

Hi,

Is there any reason that circles are approximated by polygons when
written out by vector graphics backends (i.e. SVG, PS)? Someone pointed
this out to me, and having verified it, I found it surprising. I would
think since at least SVG directly supports circles, they'd be used for
output.

This has been fixed in mpl svn for Agg and PS and will be included in
the next release, but not yet for SVG. In the "transforms" branch,
all supported backends (including Agg, PS and SVG draw "true" circles,
and the plan is to merge these changes into the main trunk sometime
after the next release.

On the branch, circles are actually approximated using cubic bezier curves. These apparently have a maximum radial error of less than 1e-3, so should be indistinguishable to the naked eye. I suspect that many rendering engines (e.g. Acrobat Reader) draw circles that way anyway for efficiency. But you still won't see "circle" elements in the SVG files.

This distinction is only important when you try to edit or analyse the resulting files -- since they aren't "logical" circles, a vector editor (e.g. inkscape), won't edit them as circles, but as paths. But since post-editing matplotlib plots is kind of problematic in a number of other ways, I don't know if that's a real problem.

(The point of all this is to reduce the number of required drawing commands in the backends to the lowest common denominator. You can draw virtually anything (with reasonable approximation) with polycurves, so that is now the only drawing primitive that mpl will ever output.)

Cheers,
Mike

···

On Nov 14, 2007 1:53 PM, Ryan May <rmay@...553...> wrote:

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA