Skip to main content

SVG path parser for matplotlib

Project description

https://github.com/nvictus/svgpath2mpl/actions/workflows/python-test.yml/badge.svg

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.

http://i.imgur.com/NcZVznQ.png

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.

Resources

See the SVG Specification.

See the matplotlib path tutorial and API docs.

License

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.

Source Distribution

svgpath2mpl-1.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

svgpath2mpl-1.0.0-py2.py3-none-any.whl (7.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file svgpath2mpl-1.0.0.tar.gz.

File metadata

  • Download URL: svgpath2mpl-1.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for svgpath2mpl-1.0.0.tar.gz
Algorithm Hash digest
SHA256 73d0eb7cc106f05a1733cdc59ecd606423e04f9274923387d53b068e65a2f805
MD5 78bd36d0dee5197ea8c9386d35eef7cc
BLAKE2b-256 c8e06589661323ebe6d15a1225fdc46123e594e958ee8b727dab1caf1ad4ddb0

See more details on using hashes here.

File details

Details for the file svgpath2mpl-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: svgpath2mpl-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for svgpath2mpl-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e6119b7b4338dbe193919541f6d7a9df2ceb41bf1cdcb138c7d62e79efe2651d
MD5 097f3ebffb83e9bb07df66906f56e6f9
BLAKE2b-256 f73a56c66bbf535483ea028895020da87d058377a8e18355f6e0e2dc1aeb2b59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page