Struct plotpy::Histogram[][src]

pub struct Histogram {
    pub colors: Vec<String>,
    pub style: String,
    pub stacked: bool,
    pub no_fill: bool,
    pub number_bins: i32,
    // some fields omitted
}
Expand description

Generates a Histogram plot

Example

// import
use plotpy::*;
use std::path::Path;

// directory to save figures
const OUT_DIR: &str = "/tmp/plotpy/doc_tests";

// set values
let values = vec![
    vec![1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 4, 5, 6], // first series
    vec![-1, -1, 0, 1, 2, 3],                    // second series
    vec![5, 6, 7, 8],                            // third series
];

// set labels
let labels = ["first".to_string(), "second".to_string(), "third".to_string()];

// configure and draw histogram
let mut histogram = Histogram::new();
histogram.draw(&values, &labels);

// add histogram to plot
let mut plot = Plot::new();
plot.add(&histogram);
plot.legend();
plot.grid_and_labels("values", "count");

// save figure
let path = Path::new(OUT_DIR).join("doc_histogram.svg");
plot.save(&path)?;

doc_histogram.svg

Fields

colors: Vec<String>

Colors for each bar

style: String

Type of histogram; e.g. “bar”

  • bar is a traditional bar-type histogram. If multiple data are given the bars are arranged side by side.
  • barstacked is a bar-type histogram where multiple data are stacked on top of each other.
  • step generates a lineplot that is by default unfilled.
  • stepfilled generates a lineplot that is by default filled.

As defined in https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html

stacked: bool

Draws stacked histogram

no_fill: bool

Skip filling bars

number_bins: i32

Number of bins

Implementations

Creates a new Histogram object

Draws histogram

Input

  • values - values
  • labels - labels

Notes

  • The type T of the input array must be a number.

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.