Skip to main content

SVG path parser for matplotlib

Project description

Parse SVG paths into matplotlib Path objects for plotting.

A path in SVG is defined by a ‘path’ element which contains a d="(path data)" attribute that contains moveto, line, curve (both cubic and quadratic Béziers), arc and closepath instructions. Matplotlib actually supports all of these instructions natively but doesn’t provide a parser or fully compatible API.

Based on:

  1. svg_parse for matplotlib by Nicolas P. Rougier (BSD license).
  2. svg.path by Lennart Regebro (MIT license).

This module adds the path commands missing from (1), including smooth curves and endpoint-parameterized elliptical arcs.

>>> from svgpath2mpl import parse_path
>>> parse_path('M 100 100 L 300 100')
Path(array([[ 100.,  100.], [ 300.,  100.]]), array([1, 2], dtype=uint8))

See the Jupyter Notebook gallery of examples.


See the SVG Specification.

See the matplotlib path tutorial and API docs.


BSD (3-Clause).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for svgpath2mpl, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size svgpath2mpl-1.0.0-py2.py3-none-any.whl (7.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size svgpath2mpl-1.0.0.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page