1use polars::prelude::*;
2
3use plotlars::{BarPlot, Legend, Orientation, Plot, Rgb, Text};
4
5fn main() {
6 let dataset = df![
7 "animal" => &["giraffe", "giraffe", "orangutan", "orangutan", "monkey", "monkey"],
8 "gender" => &vec!["female", "male", "female", "male", "female", "male"],
9 "value" => &vec![20.0f32, 25.0, 14.0, 18.0, 23.0, 31.0],
10 "error" => &vec![1.0, 0.5, 1.5, 1.0, 0.5, 1.5],
11 ]
12 .unwrap();
13
14 BarPlot::builder()
15 .data(&dataset)
16 .labels("animal")
17 .values("value")
18 .orientation(Orientation::Vertical)
19 .group("gender")
20 .error("error")
21 .colors(vec![Rgb(255, 127, 80), Rgb(64, 224, 208)])
22 .plot_title(Text::from("Bar Plot").font("Arial").size(18))
23 .x_title(Text::from("animal").font("Arial").size(15))
24 .y_title(Text::from("value").font("Arial").size(15))
25 .legend_title(Text::from("gender").font("Arial").size(15))
26 .legend(
27 &Legend::new()
28 .orientation(Orientation::Horizontal)
29 .y(1.0)
30 .x(0.4),
31 )
32 .build()
33 .plot();
34}