Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Downsampling (LTTB)

Reduce massive datasets while preserving visual shape using the Largest-Triangle-Three-Buckets algorithm. A 10M-point scatter chart becomes 5K points indistinguishable to the eye.

Python

import seraplot as sp

chart = sp.scatter(big_x, big_y).downsample(n=5000)

points = sp.lttb(list(zip(big_x, big_y)), threshold=5000)

JavaScript

import { downsampleLttb } from "seraplot";
const reduced = JSON.parse(downsampleLttb(JSON.stringify({ x, y, threshold: 5000 })));

Why LTTB?

MethodPreserves peaksSpeedVisual fidelity
Random sampleNoFastPoor
Every-NthMaybeFastOK
LTTBYesFastExcellent

Réduit les datasets massifs en préservant la forme visuelle avec l'algorithme Largest-Triangle-Three-Buckets. Un scatter de 10M points devient 5K points indistinguables à l'œil.

Python

import seraplot as sp

chart = sp.scatter(big_x, big_y).downsample(n=5000)

points = sp.lttb(list(zip(big_x, big_y)), threshold=5000)

JavaScript

import { downsampleLttb } from "seraplot";
const reduced = JSON.parse(downsampleLttb(JSON.stringify({ x, y, threshold: 5000 })));

Pourquoi LTTB ?

MéthodePréserve les picsVitesseFidélité visuelle
Échantillon aléatoireNonRapideMauvaise
Tous les NPeut-êtreRapideOK
LTTBOuiRapideExcellente