nvictus / svgpath2mpl

SVG path parser for matplotlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

svgpath2mpl

Github Actions CI

PyPI version

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.

image

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).

About

SVG path parser for matplotlib

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%