1use plotlars::{BarPlot, Legend, Orientation, Plot, Rgb, Text};
2use polars::prelude::*;
3
4fn main() {
5 let dataset = LazyCsvReader::new(PlRefPath::new("data/animal_statistics.csv"))
6 .finish()
7 .unwrap()
8 .collect()
9 .unwrap();
10
11 BarPlot::builder()
12 .data(&dataset)
13 .labels("animal")
14 .values("value")
15 .orientation(Orientation::Vertical)
16 .group("gender")
17 .sort_groups_by(|a, b| a.len().cmp(&b.len()))
18 .error("error")
19 .colors(vec![Rgb(255, 127, 80), Rgb(64, 224, 208)])
20 .plot_title(Text::from("Bar Plot").font("Arial").size(18))
21 .x_title(Text::from("animal").font("Arial").size(15))
22 .y_title(Text::from("value").font("Arial").size(15))
23 .legend_title(Text::from("gender").font("Arial").size(15))
24 .legend(
25 &Legend::new()
26 .orientation(Orientation::Horizontal)
27 .y(1.0)
28 .x(0.43),
29 )
30 .build()
31 .plot();
32}