Skip to main content

BoxPlot

Struct BoxPlot 

Source
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)>

Source

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.

Source

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)>

Source

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.

Source

pub fn horizontal_from_quartiles(y: Y, q: &Quartiles) -> Self

A horizontal box from already-computed Quartiles.

Source§

impl<C> BoxPlot<C>

Source

pub fn width(self, width: u32) -> Self

Set the box width in pixels (default 24).

Source

pub fn style(self, style: BoxStyle) -> Self

Replace the entire style block.

Source

pub fn with_style(self, f: impl FnOnce(&mut BoxStyle)) -> Self

Mutate the style in place (for tweaking one property).

Trait Implementations§

Source§

impl<C: Clone> Clone for BoxPlot<C>

Source§

fn clone(&self) -> BoxPlot<C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for BoxPlot<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C, DB: DrawingBackend> Drawable<DB> for BoxPlot<C>

Source§

fn draw<I: Iterator<Item = BackendCoord>>( &self, points: I, backend: &mut DB, _parent_dim: (u32, u32), ) -> Result<(), DrawingErrorKind<DB::ErrorType>>

Actually draws the element. The key points is already translated into the image coordinate and can be used by DC directly
Source§

impl<'a, C: 'a> PointCollection<'a, C> for &'a BoxPlot<C>

Source§

type Point = &'a C

The item in point iterator
Source§

type IntoIter = &'a [C]

The point iterator
Source§

fn point_iter(self) -> &'a [C]

framework to do the coordinate mapping

Auto Trait Implementations§

§

impl<C> Freeze for BoxPlot<C>

§

impl<C> RefUnwindSafe for BoxPlot<C>
where C: RefUnwindSafe,

§

impl<C> Send for BoxPlot<C>
where C: Send,

§

impl<C> Sync for BoxPlot<C>
where C: Sync,

§

impl<C> Unpin for BoxPlot<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for BoxPlot<C>

§

impl<C> UnwindSafe for BoxPlot<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'b, T, DB, Coord> IntoDynElement<'b, DB, Coord> for T
where T: Drawable<DB> + 'b, &'a T: for<'a> PointCollection<'a, Coord>, Coord: Clone, DB: DrawingBackend,

Source§

fn into_dyn(self) -> DynElement<'b, DB, Coord>

Make the conversion
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.