drawsvg
A Python 3 library for programmatically generating SVG (vector) images and animations. Drawsvg can also render to PNG, MP4, and display your drawings in Jupyter notebook and Jupyter lab.
What it is and what it does
drawsvg is a Python library for creating SVG vector graphics and animations through code rather than manual XML editing. It supports most common SVG elements (circles, rectangles, paths, text, arcs, markers) and nearly all SVG attributes via Python keyword arguments. The library integrates directly with Jupyter notebooks for inline display and includes an interactive widget for mouse-driven updates.
The package handles both static drawings and native SVG animations with playback controls, and can export to multiple formats. It has no runtime dependencies, making installation straightforward. The coordinate system defaults to standard SVG conventions (y increases downward), and the API uses snake_case naming throughout.
Use it for:
- Generate diagrams, charts, and technical illustrations programmatically within data science notebooks
- Create animated visualizations with SVG-native keyframe animations and playback controls
- Build interactive drawing tools in Jupyter using the DrawingWidget for mouse event handling
- Export vector graphics to PNG or video formats for presentations and reports
- Define reusable drawing patterns with gradients, clip paths, and grouped elements
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Programmatically generate SVG images and animations in Python, with support for rendering in Jupyter notebooks and exporting to PNG, MP4, and GIF formats.
Yes. Low install friction, no dependencies, active maintenance, permissive license, and a solid feature set for SVG generation and Jupyter integration make this a practical choice for anyone generating vector graphics programmatically. The recent release and 694 GitHub stars indicate a stable, used project.
Install
drawsvg on PyPI
pip
pip install drawsvguv
uv add drawsvgpoetry
poetry add drawsvgInstalling drawsvg
Before you install
Low install friction with no runtime dependencies. Actively maintained with a recent release (2 days ago) and steady repository activity.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
import drawsvg as draw
d = draw.Drawing(200, 100, origin='center')
d.append(draw.Circle(0, 0, 30, fill='red', stroke='black'))
d.save_svg('example.svg')
d # Display in Jupyter
Verify before relying
- Whether raster export (PNG, MP4, GIF) requires additional system dependencies beyond the base install
- Current state of the interactive widget in Jupyter Lab (description notes it does not yet work there)
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 895,484/month — #4,789 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: drawsvg-2.4.2-py3-none-any.whl
Keywords: SVG, draw, graphics, iPython, Jupyter, widget, animation
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
svg.pyGenerates SVG files programmatically in Python…
permissive · top 15,000 on PyPI
svgwriteCreates SVG drawings programmatically by…
permissive · top 5,000 on PyPI
aggdrawaggdraw provides high-quality 2D drawing for…
permissive · top 15,000 on PyPI
svgelementssvgelements parses SVG files and provides…
permissive · top 5,000 on PyPI
svglibSvglib reads SVG files and converts them to…
copyleft · top 5,000 on PyPI
anybadgeGenerates SVG badge images with configurable…
permissive · top 5,000 on PyPI
dash-svgProvides SVG component primitives (Svg, G,…
permissive · top 15,000 on PyPI
ppf-datamatrixGenerates datamatrix codes (2D barcodes) in SVG…
permissive · top 15,000 on PyPI
resvg_pyConverts SVG documents to raster image bytes…
unclear · top 5,000 on PyPI
wavedromConverts WaveDrom-compatible JSON…
permissive · top 15,000 on PyPI