Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

plothero

Plotly-compatible plotting for heavy signals — Rust core, Python API.

plothero is not a replacement for Plotly. It's a drop-in for the specific case where your traces are too large for Plotly.js to pan and zoom smoothly. For everything else, use Plotly directly.

plothero.graph_objects mirrors plotly.graph_objects closely enough that most Figure/Scatter code works after just swapping the import. The whole public API is also available from the top-level package, so the examples use import plothero as ph. The difference: traces above a size threshold (default 5 000 points) are automatically decimated with a Rust-accelerated LTTB, Min/Max, or M4 algorithm before being handed to Plotly.js, so a 5-million-point signal still pans and zooms smoothly in the browser.


Requirements

  • Python ≥ 3.9

Building from source additionally requires the Rust toolchain (rustc + cargo) and maturin — not needed when installing prebuilt wheels via pip install plothero. Without a compiled extension, the package still works via pure-Python fallback implementations with identical output. LTTB is about 60× slower without Rust; MinMax and M4 run at about the same speed.

Install Rust and Cargo with rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustc --version   # sanity check

macOS users can alternatively run brew install rust. If maturin develop fails with rustc, the rust compiler, is not installed or not in PATH, Rust hasn't been installed yet, or the current shell hasn't picked up ~/.cargo/env — install it (or re-run source "$HOME/.cargo/env") and try again.

could not amend shell profile: '~/.bash_profile': ... Permission denied — the rustup installer failed to add the cargo env line to ~/.bash_profile because that file isn't owned by you (or isn't writable). Rust itself is still installed correctly; you just need cargo env sourced from a profile file your shell actually reads. If you use zsh (the macOS default), add it to ~/.zprofile instead:

echo '. "$HOME/.cargo/env"' >> ~/.zprofile

Open a new terminal (or source ~/.zprofile) and rustc --version should work.


Installation

pip install plothero

Prebuilt wheels ship the compiled Rust extension, so no Rust toolchain is needed on the machine installing the package. Each wheel targets the stable Python ABI (abi3), so one wheel per platform covers Python 3.9 and newer:

Platform Architectures
Linux (manylinux) x86_64, aarch64
macOS x86_64 (Intel), arm64 (Apple Silicon)
Windows x64

On any other platform (for example musl-based Linux such as Alpine, or Windows on ARM), pip falls back to the source distribution and compiles the extension, which requires a Rust toolchain. Confirm the compiled extension is active with:

python -c "import plothero as ph; print(ph.rust_available())"  # True

Every release file is signed with PyPI and GitHub provenance attestations. See Verifying a download.

Local development

See the Development section below for the full setup, build, and test workflow. Short version:

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
maturin develop --release
pytest

Quick start

import numpy as np
import plothero as ph

t = np.linspace(0, 60, 5_000_000)  # 5M points
y = np.sin(2 * np.pi * 1.2 * t) + 0.1 * np.random.randn(len(t))

fig = ph.Figure()
fig.add_trace(ph.Scatter(x=t, y=y, mode="lines", name="PPG",
                          line=dict(color="#e41a1c", width=1)))
fig.update_layout(title="PPG Signal", xaxis_title="Time (s)", yaxis_title="Amplitude")
fig.show()               # opens in the default browser
html = fig.to_html()     # HTML string, for notebooks / dashboards

x accepts numeric arrays, datetime64, or a pandas DatetimeIndex — datetime handling is automatic, same as real Plotly.

The same figure built with real Plotly uses the same calls, only under plotly.graph_objects instead of ph. Rendering 5M raw points client-side is slow to pan/zoom (or crashes the tab entirely) without plothero's downsampling:

import numpy as np
import plotly.graph_objects as go   # <- the only line that changes

t = np.linspace(0, 60, 5_000_000)  # 5M points
y = np.sin(2 * np.pi * 1.2 * t) + 0.1 * np.random.randn(len(t))

fig = go.Figure()
fig.add_trace(go.Scatter(x=t, y=y, mode="lines", name="PPG",
                          line=dict(color="#e41a1c", width=1)))
fig.update_layout(title="PPG Signal", xaxis_title="Time (s)", yaxis_title="Amplitude")
fig.show()               # opens in the default browser
html = fig.to_html()     # HTML string, for notebooks / dashboards

Walkthrough

examples/walkthrough/ in the repository is a series of scripts that go through every feature on a real signal: the UCI household power dataset, about 2 million samples per channel with timestamps. It covers building the Rust extension, the downsampling methods, a Rust vs pure-Python benchmark, subplots, bar charts, heatmaps, export, and interactive zoom.

pip install -e ".[dev,examples]"   # adds pandas and plotly
maturin develop --release
python examples/walkthrough/01_check_install.py
python examples/walkthrough/02_overview.py   # and so on, up to 10

The dataset (about 20 MB) is downloaded on first run and cached in examples/walkthrough/data/. See examples/walkthrough/README.md for the full list.


API reference

plothero.graph_objects.Figure

Mirrors plotly.graph_objects.Figure:

Method Description
add_trace(trace, row=, col=) / add_traces([...]) Add one or more Scatter/Bar/Heatmap traces (or plain dicts). row/col (1-indexed) target a specific subplot panel — see below. Returns self.
add_scatter(row=, col=, **kwargs) Shortcut for add_trace(Scatter(**kwargs), row=row, col=col).
add_bar(row=, col=, **kwargs) Shortcut for add_trace(Bar(**kwargs), row=row, col=col).
add_heatmap(row=, col=, **kwargs) Shortcut for add_trace(Heatmap(**kwargs), row=row, col=col).
update_layout(**kwargs) Update layout — supports Plotly's magic-underscore kwargs (xaxis_title=, line_color=, ...).
update_xaxes(row=, col=, **kwargs) / update_yaxes(row=, col=, **kwargs) Update axis properties — every axis by default, or one subplot panel via row=/col=.
.data / .layout Read-only access to traces / layout.
to_dict() / to_json() Plotly JSON spec.
to_html(full_html, include_plotlyjs) HTML string ("cdn" / "inline" / False).
write_html(path) Write the figure to an HTML file.
show(*, detached=True) Serve the figure from a local HTTP server (http://127.0.0.1:<port>) and open it in the default browser. By default the server runs in a separate background process, so your script can exit while the figure stays interactive. Pass detached=False to serve from the current process instead.
to_plotly_figure() Convert to a real plotly.graph_objects.Figure (requires pip install plotly).

Figure also implements _repr_html_, so it renders inline in Jupyter.

show() hands the figure to a separate viewer process and returns immediately, so a script that processes data and then plots it finishes normally while the figure stays open, like a MATLAB figure. Zooming into a decimated trace keeps re-fetching full-resolution data from that viewer process. Each fetch also covers one screen on each side of the view, and the page caches recent windows, so panning forward and back shows real data without waiting. The viewer exits on its own shortly after you close the last browser tab showing the figure. See Downsampling → dynamic re-downsampling on zoom.

import numpy as np
import plothero as ph

t = np.linspace(0, 60, 5_000_000)
y = np.sin(2 * np.pi * 1.2 * t) + 0.1 * np.random.randn(len(t))

fig = ph.Figure()
fig.add_trace(ph.Scatter(x=t, y=y, name="signal"))
fig.show()                  # returns right away; the script can exit
# fig.show(detached=False)  # serve from this process; blocks exit until Ctrl+C

plothero.graph_objects.Scatter

Accepts the same keywords as plotly.graph_objects.Scatter — x, y, mode, name, line, marker, opacity, text, fill, hovertemplate, magic-underscore shortcuts (line_color=, marker_size=, ...). Anything not explicitly modeled is passed straight through to the Plotly.js trace spec.

Two extra keywords control the Rust-accelerated downsampling (not part of real Plotly, additive only):

Parameter Type Default Description
downsample_threshold int 5000 Downsample when len(x) > threshold.
downsample_method DownsampleMethod MINMAX MINMAX (preserves peaks/troughs — best for biomedical signals), M4 (like MINMAX but also keeps each bucket's first/last sample, at up to 2x the point cost), LTTB (best visual fidelity for smooth signals), or NONE.
import plothero as ph

ph.Scatter(x=t, y=y, mode="lines", downsample_method=ph.DownsampleMethod.LTTB,
           downsample_threshold=2_000)

plothero.graph_objects.Bar / plothero.graph_objects.Heatmap

Accept the same keywords as plotly.graph_objects.Bar / plotly.graph_objects.Heatmap — x/y/name/orientation/marker for Bar, z/x/y/name/colorscale for Heatmap — plus magic-underscore shortcuts and passthrough of anything not explicitly modeled, same as Scatter. No downsampling (categorical/gridded data, not dense signals).

fig.add_bar(x=["a", "b", "c"], y=[10, 20, 15], marker_color="#377eb8")
fig.add_heatmap(z=[[1, 20, 30], [20, 1, 60], [30, 60, 1]], colorscale="Viridis")

plothero.subplots.make_subplots

Mirrors plotly.subplots.make_subplots — builds a Figure pre-populated with a grid of axes; row/col (1-indexed, row 1 = top) route traces and axis updates to a specific panel:

import plothero as ph

fig = ph.make_subplots(rows=1, cols=2, subplot_titles=("Raw", "Filtered"))
fig.add_trace(ph.Scatter(x=t, y=raw, name="raw"), row=1, col=1)
fig.add_trace(ph.Scatter(x=t, y=filtered, name="filtered"), row=1, col=2)
fig.update_xaxes(title="Time (s)", row=1, col=1)
fig.show()

Supports shared_xaxes/shared_yaxes, horizontal_spacing/vertical_spacing, column_widths/row_heights, and subplot_titles, same as real Plotly.

Standalone downsampling functions

import numpy as np
import plothero as ph

t = np.linspace(0, 10, 1_000_000, dtype=np.float64)
y = np.sin(t)

t_small, y_small = ph.lttb_downsample(t, y, threshold=2_000)
t_small, y_small = ph.minmax_downsample(t, y, n_out=2_000)
t_small, y_small = ph.m4_downsample(t, y, n_out=2_000)

Migrating from plotly

-import plotly.graph_objects as go
+import plothero.graph_objects as go

The go alias keeps existing Plotly code unchanged. For new code, prefer import plothero as ph, which exposes the same objects (ph.Figure, ph.Scatter, ph.make_subplots, ...).

Trace/layout construction, add_trace, update_layout, to_html, show, make_subplots, and Jupyter rendering all behave the same way. Scatter, Bar, and Heatmap are implemented so far (Scatter covers line/marker plots and time series — datetime x "just works"). Multi-trace figures with plot_bgcolor, legend, margin, custom hovertemplate, etc. are supported via passthrough kwargs.


Architecture

plothero/
├── src/lib.rs              Rust: lttb_downsample, minmax_downsample, m4_downsample (PyO3 + numpy)
├── Cargo.toml               Rust package (pyo3 = "0.21", numpy = "0.21")
├── pyproject.toml           Build: maturin >= 1.4
└── plothero/
    ├── __init__.py          Re-exports the public API
    ├── graph_objects.py     Plotly-compatible Figure / Scatter / Bar / Heatmap / Layout
    ├── subplots.py          Plotly-compatible make_subplots (multi-panel figures)
    └── downsample.py        Rust dispatch + pure-Python fallback + DownsampleMethod

The Rust module is compiled as plothero._core and used transparently by Scatter.downsample(). If the compiled extension is absent, the pure-Python fallback in downsample.py is used automatically — same results, slower on large arrays. Check which backend is active with:

import plothero as ph
print(ph.rust_available())

Development

Everything below assumes you've cloned the repo and are working from its root.

1. Set up a virtual environment

python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

2. Install the Rust toolchain (one-time)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustc --version   # sanity check

3. Install dev dependencies and build the extension

pip install -e ".[dev]"     # maturin, pytest, pandas, plotly
maturin develop              # debug build, fast to compile, slower at runtime
# or: maturin develop --release   # optimized build, use this for benchmarking

maturin develop compiles src/lib.rs and installs the resulting extension as plothero._core directly into your active virtual environment — no pip install round-trip needed. Confirm it worked:

python -c "import plothero as ph; print(ph.rust_available())"  # True

If you skip steps 2–3, plothero still imports and works correctly — it silently uses the pure-Python fallback in downsample.py instead. That's fine for working on graph_objects.py, but you'll want the Rust extension built when touching src/lib.rs or benchmarking large signals.

4. Rebuild after editing Rust code

Re-run maturin develop (or --release) any time you change src/lib.rs — Python code changes under plothero/ take effect immediately, no rebuild needed.

5. Run the tests

pytest              # run the full suite
pytest -v            # verbose, one line per test
pytest tests/test_downsample.py   # just the downsampling algorithms
pytest -k datetime   # only tests matching "datetime"

The test suite (tests/) covers both layers:

  • tests/test_downsample.py — LTTB, Min/Max, and M4 downsampling correctness (shape preservation, peak/trough retention, edge cases). These tests run against whichever backend is active (Rust if built, pure-Python otherwise), so run them both before and after maturin develop if you change src/lib.rs.
  • tests/test_graph_objects.py — the Plotly-compatible API surface: Scatter/Bar/Heatmap/Layout/Figure construction, magic-underscore expansion, datetime handling, HTML/JSON output.
  • tests/test_subplots.py — make_subplots grid/domain math and its integration with Figure.add_trace/update_xaxes/update_yaxes.
  • tests/test_resample_js.py: the zoom/pan page script (padded fetches, the pan cache, stale responses), run in Node with a fake Plotly.js (tests/resample_harness.js). Skipped when node is not installed.

6. Releasing

Publishing a GitHub release whose tag is v plus the version in Cargo.toml builds and tests the wheels, publishes them to PyPI with Trusted Publishing, and attaches them to the release. Every file carries a PyPI (PEP 740) and a GitHub build provenance attestation. See Releasing in the docs for the full steps and the one-time PyPI setup, and Verifying a download to check a file's provenance. To report a vulnerability, see SECURITY.md.


Roadmap

  • More trace types (Box, Pie, Histogram) beyond Scatter, Bar, Heatmap
  • Desktop GUI rendering target (Qt/GTK), alongside the current browser/Jupyter target

Metadata

Release files for plothero 0.3.0rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plothero 0.3.0rc2
File Size Uploaded Provenance Actions
plothero-0.3.0rc2.tar.gz 136.7 kB With provenance Details for plothero-0.3.0rc2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for plothero 0.3.0rc2
File Actions
plothero-0.3.0rc2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for plothero-0.3.0rc2-cp39-abi3-win_amd64.whl
plothero-0.3.0rc2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for plothero-0.3.0rc2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
plothero-0.3.0rc2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for plothero-0.3.0rc2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
plothero-0.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for plothero-0.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl
plothero-0.3.0rc2-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for plothero-0.3.0rc2-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 1.4 MB

Release files / plothero-0.3.0rc2.tar.gz

Download URL plothero-0.3.0rc2.tar.gz
Size 136.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e1984ae5e5384f67c0595b4f6d5e8e8472fd54bf478aece139e8be434088c9ca
BLAKE2b-256 checksum
How to use checksums
6ea434c4527c92b1edfa13568b3f48a81c349157e879eb73031a70a9aff8df67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / plothero-0.3.0rc2-cp39-abi3-win_amd64.whl

Download URL plothero-0.3.0rc2-cp39-abi3-win_amd64.whl
Size 181.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
61cad9f7e31e0198a4d93e310308a60b5a7f06cea53b18cf38fea52bdb31ca4e
BLAKE2b-256 checksum
How to use checksums
14958fff444bfc587d3167d0a186bbb3ac5beb8dbbfe81d8db20e9249c6414f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / plothero-0.3.0rc2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL plothero-0.3.0rc2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 279.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
07ca3b9b5488c0f6510c9014015ae136c89f3bc617c019bbf93adcd5525ae3ba
BLAKE2b-256 checksum
How to use checksums
ed8854b602b33fc5db8d21b40ea539eb35e8a1a5793dc79a0d860b659c80bbd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / plothero-0.3.0rc2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL plothero-0.3.0rc2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 279.8 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
75ccabe5d26d886110bbeed370d82e1fb1f38d2322298c37e0f9fcdac4ffea28
BLAKE2b-256 checksum
How to use checksums
f7deaa442285f775ede98e54d871f21aea14acd68183447412bb88f889c81485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / plothero-0.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl

Download URL plothero-0.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl
Size 261.0 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bcf615a2f33d6a97286f74e01128baae07046882f53a7fbb2a179cf22b9756de
BLAKE2b-256 checksum
How to use checksums
b846bc845d48c31d37032994a61c8739dbde259b3a43a13ed67b82d2b20523d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / plothero-0.3.0rc2-cp39-abi3-macosx_10_12_x86_64.whl

Download URL plothero-0.3.0rc2-cp39-abi3-macosx_10_12_x86_64.whl
Size 268.6 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4998fce8e038755d6b1c9c69aa2a8468d8ac6e803f9d6f9a2a8b02816b24cdee
BLAKE2b-256 checksum
How to use checksums
ba504086d0de212ae28b6344eb1ef9fcc71380946a879457362c2a8334d395eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for plothero 0.3.0rc2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for plothero-0.3.0rc2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page