Expand description
§MinMaxLTTB - MinMax Largest Triangle Three Buckets
This crate provides implementations of the LTTB (Largest Triangle Three Buckets) and MinMaxLTTB algorithm for downsampling timeseries data for visualization purposes.
§Variants
- Classic LTTB: Classic implementation of LTTB downsampling using buckets with equal number of points
- Standard LTTB: Alternative implementation of classic LTTB downsampling using buckets with equal x-axis range
- MinMax LTTB: MinMax variant that preserves local minima and maxima and is more computationally efficient
§Usage
use minmaxlttb::{Point, Lttb, LttbBuilder, LttbMethod, Binning};
// E.g., usage with convenience functions
let points = vec![
Point::new(0.0, 1.0),
Point::new(1.0, 2.0),
Point::new(2.0, 3.0),
Point::new(3.0, 4.0),
];
// Classic LTTB (equal-count buckets)
let classic = minmaxlttb::lttb(&points, 3, Binning::ByCount).unwrap();
// Standard LTTB (equal x-range buckets)
let standard = minmaxlttb::lttb(&points, 3, Binning::ByRange).unwrap();
// Advanced usage with builder pattern, e.g., using MinMax LTTB with ratio=3
let lttb = LttbBuilder::new()
.threshold(3)
.method(LttbMethod::MinMax)
.ratio(3)
.build();
let result = lttb.downsample(&points).unwrap();
// Reuse the same configuration for multiple datasets
let dataset1 = vec![Point::new(0.0, 10.0), Point::new(1.0, 20.0), Point::new(2.0, 30.0), Point::new(3.0, 40.0)];
let dataset2 = vec![Point::new(0.0, 30.0), Point::new(1.0, 40.0), Point::new(2.0, 50.0), Point::new(3.0, 60.0)];
let lttb = LttbBuilder::new()
.threshold(3)
.method(LttbMethod::Classic)
.build();
let result1 = lttb.downsample(&dataset1).unwrap();
let result2 = lttb.downsample(&dataset2).unwrap();Structs§
- Lttb
- LTTB downsampler that can be used on a
Vec<Point>to downsample it to the selected threshold - Lttb
Builder - Builder for configuring LTTB downsampling parameters with MinMax LTTB as default
- Point
- Defines a
Pointwith x and y coordinates
Enums§
- Binning
- Method to use for splitting the points into buckets
- Lttb
Error - Error returned by LTTB downsampling
- Lttb
Method - Method to use for downsampling
Functions§
- bucket_
limits_ by_ count - Returns a vector of all bucket boundaries (indices) using floating-point arithmetic such that the number of points in each bucket is equal (by count)
- bucket_
limits_ by_ range - Returns a vector of all bucket boundaries (indices) such that all buckets have the same x-axis range
- extrema_
selection - Preselect the extrema points for each bucket using the MinMax algorithm
- find_
minmax - Returns the MIN and MAX points in a slice of points as a vector where the MIN point has the lowest Y value and the MAX point has the highest Y value.
- lttb
- Downsample using the LTTB algorithm with a given binning method.
- mean_
point_ bucket - Returns the mean
Pointfor a slice of points by computing the average of the x and y coordinates ReturnsNoneif the slice of points is empty - minmaxlttb
- Downsample using the MinMax LTTB algorithm.
- partition_
bounds_ by_ range - Return a vector of all partition boundaries (indices) such that the all partitions have the same x-axis range
- partition_
limits_ by_ count - Return a vector of all partition boundaries (indices) using floating-point arithmetic such that the number of points in each partition is equal (by count)