Struct Histogram

Source
pub struct Histogram {
    pub bin_bounds: Vec<f64>,
    pub bin_counts: Vec<f64>,
    pub bin_densities: Vec<f64>,
    /* private fields */
}
Expand description

A one-dimensional histogram with equal binning.

Fields§

§bin_bounds: Vec<f64>§bin_counts: Vec<f64>§bin_densities: Vec<f64>

Implementations§

Source§

impl Histogram

Source

pub fn from_slice(v: &[f64], bins: HistogramBins) -> Histogram

Examples found in repository?
examples/histogram_text.rs (line 7)
5fn main() {
6    let data = [0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
7    let h = Histogram::from_slice(&data, HistogramBins::Count(10));
8
9    let v = ContinuousView::new().add(h);
10
11    println!("{}", Page::single(&v).dimensions(60, 15).to_text().unwrap());
12}
More examples
Hide additional examples
examples/histogram_svg.rs (line 8)
6fn main() {
7    let data = [0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
8    let h = Histogram::from_slice(&data, HistogramBins::Count(10))
9        .style(&BoxStyle::new().fill("burlywood"));
10
11    let v = ContinuousView::new().add(h);
12
13    Page::single(&v).save("histogram.svg").expect("saving svg");
14}
Source

pub fn num_bins(&self) -> usize

Source

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

Examples found in repository?
examples/histogram_svg.rs (line 9)
6fn main() {
7    let data = [0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
8    let h = Histogram::from_slice(&data, HistogramBins::Count(10))
9        .style(&BoxStyle::new().fill("burlywood"));
10
11    let v = ContinuousView::new().add(h);
12
13    Page::single(&v).save("histogram.svg").expect("saving svg");
14}
Source

pub fn density(self) -> Self

Set the histogram to display as normalised densities

Source

pub fn get_style(&self) -> &BoxStyle

Source

pub fn get_values(&self) -> &[f64]

Trait Implementations§

Source§

impl ContinuousRepresentation for Histogram

Source§

fn range(&self, dim: u32) -> (f64, f64)

The maximum range in each dimension. Used for auto-scaling axes.
Source§

fn to_svg( &self, x_axis: &ContinuousAxis, y_axis: &ContinuousAxis, face_width: f64, face_height: f64, ) -> Group

Source§

fn legend_svg(&self) -> Option<Group>

Returns None if no legend has been specified for this representation
Source§

fn to_text( &self, x_axis: &ContinuousAxis, y_axis: &ContinuousAxis, face_width: u32, face_height: u32, ) -> String

Source§

impl Debug for Histogram

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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