Skip to main content

plotlars_core/components/
bar_mode.rs

1/// An enumeration representing how bars are displayed when multiple bar traces share the same axis.
2///
3/// # Example
4///
5/// ```rust
6/// use plotlars::{BarMode, BarPlot, Plot};
7/// use polars::prelude::*;
8///
9/// let dataset = df![
10///         "animal" => &["giraffe", "giraffe", "orangutan", "orangutan", "monkey", "monkey"],
11///         "gender" => &["female", "male", "female", "male", "female", "male"],
12///         "value" => &[20.0f32, 25.0, 14.0, 18.0, 23.0, 31.0],
13///     ]
14///     .unwrap();
15///
16/// BarPlot::builder()
17///     .data(&dataset)
18///     .labels("animal")
19///     .values("value")
20///     .group("gender")
21///     .mode(BarMode::Stack)
22///     .build()
23///     .plot();
24/// ```
25///
26/// ![Example](https://imgur.com/HQQvQey.png)
27#[derive(Clone)]
28pub enum BarMode {
29    Stack,
30    Group,
31    Overlay,
32    Relative,
33}