Skip to main content

anyplotlib

codecov Tests

anyplotlib is a fast, interactive plotting library for Jupyter, built on anywidget and a pure-JavaScript canvas renderer. It follows matplotlib's object-oriented API — create a Figure, call methods on Axes — so switching is often a one-line change:

import anyplotlib as apl

fig, ax = apl.subplots(1, 1)        # same shape as plt.subplots(1, 1)
ax.imshow(data)                     # pan, zoom, and inspect — live
fig                                 # display in a Jupyter cell

If you have used matplotlib's OO interface, you already know most of anyplotlib. What you gain is interactivity that stays fast on large data — without a kernel round-trip per frame.

Why another plotting library?

Matplotlib is a superb tool for publication-quality static figures, but its interactive notebook story (ipympl) re-renders the whole figure on the Python side for every frame. anyplotlib makes the opposite trade-off:

  • All rendering happens in the browser. Python serialises compact state (raw image bytes, base64-encoded float arrays) once; pan/zoom/drag never touch the kernel.
  • Each image, line collection, or marker group is a single canvas object, so blitting works and drag interactions run at full frame rate.
  • The scope is deliberately limited. The OO API only (no plt.plot() global state), a curated set of plot types and marker styles, and raster canvas output rather than vector graphics. For print-quality SVG/PDF figures, matplotlib remains the right tool.

Features

  • Plot typesplot (1-D lines with markers, linestyles, legends, log y), imshow (2-D images with colormaps, colorbars, scale bars, overlay masks), pcolormesh (non-uniform 2-D meshes), bar (grouped, horizontal, log, value labels), and 3-D plot_surface / scatter3d / plot3d.
  • Layoutssubplots, matplotlib-compatible GridSpec indexing (slices, spans, negative indices), width_ratios/height_ratios, sharex/sharey linked pan-zoom, and floating inset axes with minimize/maximize.
  • Markers — static overlays (points, circles, ellipses, rectangles, polygons, arrows, line segments, text, h/v lines) with matplotlib-style kwargs and live .set() updates.
  • Widgets — draggable overlays (RectangleWidget, CircleWidget, AnnularWidget, CrosshairWidget, PolygonWidget, VLineWidget, HLineWidget, RangeWidget, …) that report positions back to Python.
  • Events — a two-tier callback system: pointer_move fires every drag frame for cheap updates; pointer_settled / pointer_up fire once for expensive recomputation. Plus key_down, wheel, double_click, and per-line scoped handlers.
  • Interactive docs — the bundled anyplotlib.sphinx_anywidget extension makes any anywidget figure live in Sphinx Gallery pages via Pyodide — no kernel or server needed.
  • Embeddable anywhere — figures don't require Jupyter. Export self-contained HTML (fig.save_html("plot.html")), mount the renderer directly in an Electron app or web page via the JS mount() API, or run a live Python backend over any transport with anyplotlib.embed.FigureBridge (full callback support). See the embedding guide in the docs.
import numpy as np
import anyplotlib as apl

fig, (ax_img, ax_spec) = apl.subplots(1, 2, figsize=(900, 400))
img  = ax_img.imshow(stack.mean(axis=2), cmap="viridis")
spec = ax_spec.plot(stack[64, 64], units="eV")

cross = img.add_widget("crosshair", cx=64, cy=64)

@cross.add_event_handler("pointer_move")   # every drag frame — keep it cheap
def update(event):
    spec.set_data(stack[int(cross.cy), int(cross.cx)])

Installation

pip install anyplotlib

Works anywhere anywidget does: JupyterLab, Jupyter Notebook, VS Code, PyCharm, Google Colab, and marimo. Dependencies are intentionally light: anywidget, numpy, traitlets, and colorcet (no matplotlib required).

Documentation

Full docs, a live example gallery (interactive in the browser — no install), and the event-system guide are at cssfrancis.github.io/anyplotlib.

Development

git clone https://github.com/CSSFrancis/anyplotlib
cd anyplotlib
uv sync                              # install with dev dependencies
uv run playwright install chromium   # browsers for rendering tests
uv run pytest                        # full suite (unit + Playwright + visual)
make html                            # build the docs locally

The architecture is a single anywidget.AnyWidget (Figure) that owns all traitlets; plot objects are plain Python classes that serialise their state dicts to per-panel traits, and figure_esm.js renders them. See AGENTS.md for the codebase guide and anyplotlib/FIGURE_ESM.md for a map of the JS renderer.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyplotlib-0.5.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyplotlib-0.5.0-py3-none-any.whl (293.6 kB view details)

Uploaded Python 3

File details

Details for the file anyplotlib-0.5.0.tar.gz.

File metadata

  • Download URL: anyplotlib-0.5.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for anyplotlib-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7e6eaa5fec412671e164015bb2ea46c001b3b179f95f8a722fc393cc91917fab
MD5 5849dee2c532f49757058761e577ab23
BLAKE2b-256 7f5c5cc19afcd273d026648b5b32a19e8686eb3c21df53274644f388829fb6dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyplotlib-0.5.0.tar.gz:

Publisher: release.yml on CSSFrancis/anyplotlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyplotlib-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: anyplotlib-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 293.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for anyplotlib-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 038e6ccebdbfc261cdeed88b9a1b1288e8f55392ca6fcf5f78b95ef72d6f2f4a
MD5 321e74c21200a79b9661216b8ac15e5d
BLAKE2b-256 f6f41dbcb72a5030c105a85ee85a864490af13a508088a4fb5b366153bebdb32

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyplotlib-0.5.0-py3-none-any.whl:

Publisher: release.yml on CSSFrancis/anyplotlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page