pub struct BoxPlot<C> { /* private fields */ }Expand description
A single box-and-whisker, positioned at one coordinate on the category axis.
Generic over the full chart coordinate C so the same type serves both
orientations: a vertical box lives on a (X, f64) chart, a
horizontal box on a (f64, Y) chart. Use BoxPlot::vertical /
BoxPlot::horizontal to construct one; the width is measured in pixels,
so it is independent of the axis scale.
use plotters::prelude::*;
use plotters_statistical::BoxPlot;
let root = SVGBackend::new("one_box.svg", (400, 300)).into_drawing_area();
let mut chart = ChartBuilder::on(&root)
.build_cartesian_2d(0.5f64..1.5f64, 0f64..10f64)?;
let bx = BoxPlot::vertical(1.0f64, &[1.0, 2.0, 3.0, 4.0, 9.0])?;
chart.draw_series(std::iter::once(bx))?;Implementations§
Source§impl<X: Clone> BoxPlot<(X, f64)>
impl<X: Clone> BoxPlot<(X, f64)>
Sourcepub fn vertical(x: X, data: &[f64]) -> Result<Self, StatsError>
pub fn vertical(x: X, data: &[f64]) -> Result<Self, StatsError>
A vertical box at category position x, computed from a raw data
sample. Errors if the sample has no finite values.
Sourcepub fn vertical_from_quartiles(x: X, q: &Quartiles) -> Self
pub fn vertical_from_quartiles(x: X, q: &Quartiles) -> Self
A vertical box from already-computed Quartiles — useful when the
summary was produced elsewhere (e.g. streamed) and the raw sample is no
longer held.
Source§impl<Y: Clone> BoxPlot<(f64, Y)>
impl<Y: Clone> BoxPlot<(f64, Y)>
Sourcepub fn horizontal(y: Y, data: &[f64]) -> Result<Self, StatsError>
pub fn horizontal(y: Y, data: &[f64]) -> Result<Self, StatsError>
A horizontal box at category position y, computed from a raw data
sample. Errors if the sample has no finite values.
Sourcepub fn horizontal_from_quartiles(y: Y, q: &Quartiles) -> Self
pub fn horizontal_from_quartiles(y: Y, q: &Quartiles) -> Self
A horizontal box from already-computed Quartiles.