skillfed

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.

drawsvg v2.4.2 895.5K downloads/30d#4,789 on PyPI694
Permissive license Active released

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 drawsvg

uv

uv add drawsvg

poetry

poetry add drawsvg

Installing 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

Framework :: IPythonFramework :: JupyterLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3

Tags

SVG generation Pythonprogrammatic vector graphicsJupyter drawing librarySVG animation Pythoncreate SVG images code
jupyter-integrationvector-graphicsanimation

More Graphics packages