Small, hackable Python library that emits matplotlib-style SVG plots.
Project description
plotlet
A small, hackable Python library that emits matplotlib-style SVG plots.
Why
matplotlib is the right tool when you want the kitchen sink. plotlet's niche is custom plot types — genome tracks, Manhattan plots, phylogenetic trees, anything matplotlib's extension API makes painful. The whole library is ~700 lines of Python with a deliberately tiny, exposed core: adding a new plot type is a 3-step recipe, not an architecture project.
It's a scaffold, not a feature catalog: the core ships ~5 standard plots and the infrastructure for extending. Custom plot types live in your own project (or cookbook/), not upstream. See docs/PHILOSOPHY.md for the full framing.
import plotlet as pt
data = {
"x": [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
"y": [1, 4, 9, 16, 25, 1, 8, 27, 64, 125],
"series": ["squares"] * 5 + ["cubes"] * 5,
}
c = pt.chart(data, title="Hello", xlabel="x", ylabel="y", legend=True, grid=True)
c.line(x="x", y="y", hue="series")
c # auto-renders in Jupyter
Install
Not on PyPI yet — clone and install editable:
git clone <repo>
cd plotlet
pip install -e .
Properties
- Lightweight.
fonttoolsfor font handling. numpy / pandas / polars inputs work transparently if you have them. - Static SVG output. No interactivity, no animation. Same script → byte-identical SVG.
- Cross-machine reproducible. Bundled DejaVu Sans + text-as-paths means rendering is identical on Linux, macOS, Windows, headless CI.
- Jupyter-native.
Figure._repr_html_auto-renders the last expression in a cell. - Tiny output. Each plot is ~50 KB SVG, self-contained.
API
pt.chart(data, **opts) returns a Chart bound to a table — any object that supports data[col_name] returning an iterable (pandas / polars DataFrames, dict-of-lists, dict-of-arrays). All methods return self; _repr_html_ makes the chart auto-render as the last expression in a Jupyter cell.
Frame options
Pass at construction (pt.chart(data, title=..., grid=True, ...)) or as chained setters (c.title(...), etc.):
title, xlabel, ylabel, xlim=(a, b), ylim=(a, b), xscale="log"|"linear", yscale=..., grid=True/False, legend=True/False, width, height
Mark methods
| call | options |
|---|---|
.line(x=, y=, hue=, **opts) |
color, label, linewidth, linestyle ("-", "--", ":", "-."), marker ("o", "s", "^", "v", "x", "+"), markersize |
.scatter(x=, y=, hue=, **opts) |
color, label, s (size), alpha, marker |
.bar(x=, y=, **opts) |
color, label, alpha |
.hist(x=, **opts) |
bins, color, alpha, label |
.fill_between(x=, y1=, y2=, **opts) |
color, alpha, label |
hue=<col> (on .line / .scatter) splits into one call per unique value with auto-labels and tab10 colors.
Render / save
c.show() # explicit display() inside a cell
c.to_svg() # raw SVG string
c.save_svg("plot.svg") # SVG file
c.write_html("plot.html") # standalone HTML
Color shortcuts
"C0"–"C9"→ tab10 (matches matplotlib)- Named:
"blue","orange","green","red","purple","brown","pink","gray","olive","cyan" - Single-letter:
"k","w","b","g","r" - Any hex / CSS color string passes through
Adding a new plot type
plotlet's central hackability claim: a custom plot type is a 3-step recipe (~50–100 lines) that gets axes, scales, legend, grid, and composability for free. The recommended home is your own project, or cookbook/ as reference. Full guide: docs/EXTENDING.md.
Testing
python tests/test_chart.py # check vs. committed baselines
python tests/test_chart.py --update # regenerate (review the diff!)
python tests/test_chart.py --gallery # build tests/baseline_images/chart/index.html
Non-goals
- No interactivity (hover, zoom, click). Static rendering is the point.
- Not competing with matplotlib on standard plots; matplotlib is bigger and battle-tested.
- Not a 3D plotter, not a dashboard tool.
- Not a feature catalog — new plot types belong in user projects or
cookbook/, not in the core.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plotlet-0.1.0.tar.gz.
File metadata
- Download URL: plotlet-0.1.0.tar.gz
- Upload date:
- Size: 400.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7bd5befbd4bb6baa59d45c9788c319a51a7dfb7c397eeed5d09bac970fba8fc
|
|
| MD5 |
cae8bff759e8ee84481884acb325c274
|
|
| BLAKE2b-256 |
fa3007f37e5263a0dee40446c0a90c9f21807e943ea0cd5c27e7c9ab07d8e2b6
|
File details
Details for the file plotlet-0.1.0-py3-none-any.whl.
File metadata
- Download URL: plotlet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 396.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
803721cfea5ea84b1871fa87a652c4a26e228f5b49dabad8fc3ec997477bbb92
|
|
| MD5 |
7b735a5a9c2d9de065ea97398d209492
|
|
| BLAKE2b-256 |
445dae128bc9fc43752d058d8a056ee0e0cddc81d39d82b14a580c684f610f5f
|