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.
  • Bands. Pass several y series that share x, such as mu ± sigma or a min/max envelope, as a (len(x), k) array or a list of arrays: simplify(t, [lo, hi]). You get one set of indices, and every series is within eps of its drawn line. Simplifying each edge separately and taking the union of the indices doesn't give that: the extra points split the other edge's segments, and its error can reach 2 * eps. The joint pass also keeps fewer points. A point is a gap if any series is NaN there.
  • 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.2.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.2.0
File Size Uploaded Provenance Actions
plotsimplify-0.2.0.tar.gz 32.6 kB With provenance Details for plotsimplify-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for plotsimplify 0.2.0
File Actions
plotsimplify-0.2.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for plotsimplify-0.2.0-cp311-abi3-win_amd64.whl
plotsimplify-0.2.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.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
plotsimplify-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for plotsimplify-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
plotsimplify-0.2.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for plotsimplify-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
plotsimplify-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for plotsimplify-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 1.2 MB

Release files / plotsimplify-0.2.0.tar.gz

Download URL plotsimplify-0.2.0.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d8682a599761e4ccdee203bbb6f6eb0205aab13943bef75af0315e350552b904
BLAKE2b-256 checksum
How to use checksums
6c19034ca7c21421b54ff92e247dfe66459f99027cde4b94d5f277f9c8c2f929
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 26, 2026.

Transparency log

Release files / plotsimplify-0.2.0-cp311-abi3-win_amd64.whl

Download URL plotsimplify-0.2.0-cp311-abi3-win_amd64.whl
Size 146.5 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e6a2c1316e2d0fe924644b5170c9899e0a3442fcb25f54dca0a28001029d03ad
BLAKE2b-256 checksum
How to use checksums
2faef5607818496750e537d659f062aacb05370c743debc40bbea295132055cf
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 26, 2026.

Transparency log

Release files / plotsimplify-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL plotsimplify-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 250.6 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
169d5d34777388c1a3036720cd46864c854c48fb4a514c61116d7e95a25aecfe
BLAKE2b-256 checksum
How to use checksums
ebf34a15165d83996b337b99b81b97e51f25b82d708d2e5b41e1cd97c95ace39
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 26, 2026.

Transparency log

Release files / plotsimplify-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL plotsimplify-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 245.8 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
46a1905f95801694aa77e13908c5ded8b91cf538cdf9f74fa6916643d887f42f
BLAKE2b-256 checksum
How to use checksums
824fef0151ffb5fb74fa2130763f87b053ceab6daa642760fd7a6041b30620bf
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 26, 2026.

Transparency log

Release files / plotsimplify-0.2.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL plotsimplify-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Size 231.9 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
943eb081d3d5ec244f456f68ee388a368625448660795bed0b9faf8b670abe38
BLAKE2b-256 checksum
How to use checksums
ec3e0d73337462c141d324ea3b0ee616346e79d6933b0f1ca93ec8be7dcd78ee
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 26, 2026.

Transparency log

Release files / plotsimplify-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL plotsimplify-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 244.1 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
463b9d855cbaf081f639462f4a8c91f6c245de35208f58af707ab8f875ff52f7
BLAKE2b-256 checksum
How to use checksums
c8aa977a71b66ab8e0958fe05eb30a788b8547ef376f5b7e68dd4cbfea1062ad
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 26, 2026.

Transparency log

Security for plotsimplify 0.2.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.2.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 26, 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.2.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