Skip to main content

plotsimplify

Shrinks a time series to only the points needed to draw it, using Ramer–Douglas–Peucker (RDP) with an error bound you set in pixels. The kernel is Rust (SIMD, with runtime CPU dispatch and the GIL released), exposed to Python via PyO3.

import numpy as np
from plotsimplify import simplify

t = np.datetime64("2026-01-01", "ns") + np.arange(n) * np.timedelta64(1, "s")
y = ...  # float values; NaN = gap

r = simplify(t, y, width_px=1200, height_px=400)   # eps=0.5 px by default
t_small, y_small = t[r.indices], y[r.indices]
r.max_error    # worst error of the result, in pixels (<= eps unless max_points cut it short)

On a 1M-point sensor series plotted at 1200×400 px, this keeps about 2,400 points in 20 ms, and every dropped point is within half a pixel of the line that's drawn.

Why

Sending or plotting millions of points is slow, and most of them are invisible. Python already has two kinds of tools for this, and neither fits:

  • RDP libraries aren't built for time series.
    • The rdp package is pure Python, about 70x slower than a plain loop, and fails on NumPy 2.
    • simplification (Rust geo) and shapely are compiled, but they're written for general geometry. They have no notion of pixels, datetimes or NaN gaps, and simplification is 7–9x slower than this package (see below).
  • Fixed-budget downsamplers such as tsdownsample (LTTB, MinMax, M4) are very fast and give you exactly n_out points, but they don't bound the error. They aim to look right at pixel resolution, not to stay close to the line. With the same number of points on plateau-and-ramp test data, their worst error was 12–16x larger than RDP's.

docs/downsampling-report.md has the full comparison of methods and libraries.

Install

pip install plotsimplify

Prebuilt abi3 wheels (Linux/macOS/Windows, x86-64 and arm64, Python 3.11+). The only dependency is NumPy.

Features

  • Error in pixels. Pass the plot's width_px/height_px and eps is in pixels. Without them, eps is in data units.
  • Two distance metrics.
    • metric="vertical" (default) measures distance straight up/down from the drawn line. It guarantees max |y - drawn line| <= eps and is the fastest.
    • metric="perpendicular" measures Euclidean distance to the drawn segment. It's clamped to the segment's endpoints, so a spike just past the end of a steep ramp isn't dropped. RDP using the infinite line would drop it.
  • max_points. Segments are split largest-error-first, so a budget gives you the most important points in one pass, and max_error reports the error you actually got.
  • Gaps. Points with NaN y or NaT x are dropped, except the first point of each gap. It's kept so the plot breaks the line instead of joining across the gap.
  • Timestamps. datetime64 and integer x are handled without losing precision. x must be sorted.
  • Returns indices, so you can pick timestamps, other columns or metadata from your original arrays.
  • y_range=(lo, hi) if the plot has a fixed y-axis rather than one that auto-scales to the data.

Benchmarks

Intel Xeon W-2123 (AVX-512), one thread, synthetic sensor data at 1 sample/s with one outage, plotted at 1200×400 px, eps=0.5 px. Source: benchmarks/bench.py, raw output in benchmarks/results.txt.

N case plotsimplify pure NumPy RDP simplification (Rust geo) points kept
100k vertical 3.8 ms 126 ms – 7,334
100k perpendicular 4.0 ms 115 ms 38 ms 1,871
1M vertical 21 ms 107 ms – 2,386
1M perpendicular 32 ms 327 ms 216 ms 1,072
1M vertical, max_points=1000 19 ms 93 ms – 1,000
10M vertical 255 ms 1,664 ms – 14,117
10M perpendicular 345 ms 6,560 ms 3,125 ms 3,377
  • simplification only has perpendicular distance, so it appears only in those rows. It's given the same pixel-scaled coordinates. Its time includes that scaling and dropping NaNs, since it can't handle gaps.
  • The "pure NumPy RDP" column is the test suite's reference implementation (tests/reference_kernel.py): the same algorithm with the inner search vectorized. It's a good stand-in for what you'd get writing RDP in NumPy yourself.

How it's fast

  • The farthest-point search uses 8 independent lanes, so the compiler can turn it into SIMD. Ties go to the lowest index.
  • Runtime CPU dispatch. Wheels are built for baseline x86-64, so the hot loops are also compiled for AVX-512 and AVX2 and chosen at startup. plotsimplify.simd_level() reports which path is in use. Without dispatch, a portable wheel lost about a third of its speed. arm64 builds use the generic loops with NEON; that path isn't benchmarked yet.
  • FMA stays off. Fused multiply-add would round differently, so every SIMD path gives bit-identical output, and the output matches a plain NumPy implementation. The tests check both.
  • Perpendicular distance is computed branch-free: all three cases are computed and one is selected, so it vectorizes too.
  • The input scan is one fused pass, because it's memory-bound: the number of passes over the data is what costs.
  • Pixel scaling is free for vertical. Vertical pixel distance is just data distance times a constant, so eps is converted instead of the arrays.

Using it in a web service

  • Simplify only the visible range. Slice to the zoom window with np.searchsorted first, then simplify. Zooming in brings back detail.
  • Cap the payload. Zoomed in, sensor noise can be several pixels tall, and RDP keeps noise. max_points=4 * width_px is a reasonable cap.
  • Use a sync endpoint. In FastAPI, a plain def endpoint runs in the thread pool, and simplify releases the GIL, so concurrent requests run in parallel.
  • Gaps in JSON. Send y[r.indices] with NaN gap markers as null; plotting libraries draw a break there.

Development

cargo test --no-default-features
pip install -e '.[dev]' && maturin develop --release
pytest    # includes bit-identical checks vs the NumPy reference and the non-SIMD path
pip install simplification && python benchmarks/bench.py

License

MIT

Metadata

Release files for plotsimplify 0.1.0

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

Source distribution (sdist)

Source distribution for plotsimplify 0.1.0
File Size Uploaded Provenance Actions
plotsimplify-0.1.0.tar.gz 29.6 kB With provenance Details for plotsimplify-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for plotsimplify 0.1.0
File Actions
plotsimplify-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for plotsimplify-0.1.0-cp311-abi3-win_amd64.whl
plotsimplify-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for plotsimplify-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
plotsimplify-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for plotsimplify-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
plotsimplify-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for plotsimplify-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
plotsimplify-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for plotsimplify-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 1.1 MB

Release files / plotsimplify-0.1.0.tar.gz

Download URL plotsimplify-0.1.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
68f8ee0fa2fd42c59f46b408f59b5e313fd667f5111cf3cbaca5f6e6b140967e
BLAKE2b-256 checksum
How to use checksums
c820769552252d5747b5a6fb77ace9dbb94f5e3236ef017115a5b7964cbffecf
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 / plotsimplify-0.1.0-cp311-abi3-win_amd64.whl

Download URL plotsimplify-0.1.0-cp311-abi3-win_amd64.whl
Size 143.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7ca123c29ad1e42f4fa914e97a992ebe8744edd6ec5e45e92822918054125ef6
BLAKE2b-256 checksum
How to use checksums
4e2f0e6fd9af589f65ddf752125c5735f83f925bd5cbe2ecc584544693110516
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 / plotsimplify-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL plotsimplify-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 248.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2f19b3d19cba23ce2ca3b8649e83e20b9a635d11d15a0e490b178e1b1ad4f0a6
BLAKE2b-256 checksum
How to use checksums
c5a8f617a6d44593e64daf04db702d788f9e0096fe388ed742757491b54f5fbf
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 / plotsimplify-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL plotsimplify-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 243.1 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b9c646f1259bf794919067fcfd3a916b218f01538e41e9f15c770b07c8c16a99
BLAKE2b-256 checksum
How to use checksums
1feafca733218239212b702424a46c719573e3c4f91743888017e597d196a985
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 / plotsimplify-0.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL plotsimplify-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 229.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
95f7ba8e20b48d48ccd104e0211e5a0f2c66f72d3e21c6b511b47ae503a04169
BLAKE2b-256 checksum
How to use checksums
0bbac3ab6af18f731d7eb42ed624ac9f42d7bd3c1150893828c4f55a059db016
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 / plotsimplify-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL plotsimplify-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 241.5 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
83d4bfc2d9928efc0fccc5e38ff76abd8aea4a6c722a47b2ddb52a095ba0adc9
BLAKE2b-256 checksum
How to use checksums
69a0ffd8aadbf2e6f72d5d87eba9b3ccd12886b0628208645f3d395a36b50e2f
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 plotsimplify 0.1.0

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 plotsimplify-0.1.0.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files Full provenance

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