Skip to main content

bar_grouped/
bar_grouped.rs

1use bland::{Figure, Hatch, PaperSize};
2
3fn main() {
4    let cats = ["A", "B", "C", "D"];
5
6    let fig = Figure::new()
7        .size(PaperSize::A5Landscape)
8        .title("Test bench results")
9        .xlabel("specimen")
10        .ylabel("yield (MPa)")
11        .bar(&cats, &[320.0, 290.0, 410.0, 355.0], |b| {
12            b.label("trial 1").hatch(Hatch::Diagonal).group(0)
13        })
14        .bar(&cats, &[345.0, 305.0, 395.0, 380.0], |b| {
15            b.label("trial 2").hatch(Hatch::Crosshatch).group(1)
16        })
17        .legend_top_left();
18
19    std::fs::create_dir_all("out").expect("create out/");
20    std::fs::write("out/bar_grouped.svg", fig.to_svg()).expect("write svg");
21    println!("wrote out/bar_grouped.svg");
22}