bland 0.2.1

Pure-Rust library for paper-ready, monochrome, hatch-patterned technical plots in the visual tradition of 1960s-80s engineering reports.
Documentation
use bland::{Figure, PaperSize, Stroke, TextAnchor};

fn main() {
    let xs: Vec<f64> = (0..=200).map(|i| i as f64 / 20.0).collect();
    let ys: Vec<f64> = xs.iter().map(|t| (-t / 4.0).exp() * t.cos()).collect();

    // Find the global maximum.
    let (idx, &peak_y) = ys
        .iter()
        .enumerate()
        .max_by(|a, b| a.1.partial_cmp(b.1).unwrap())
        .unwrap();
    let peak_x = xs[idx];

    let fig = Figure::new()
        .size(PaperSize::A5Landscape)
        .title("Annotated peak")
        .xlabel("t [s]")
        .ylabel("x(t)")
        .line(&xs, &ys, |s| s.stroke(Stroke::Solid))
        .annotate_arrow((peak_x + 1.0, peak_y - 0.4), (peak_x, peak_y))
        .annotate_text(peak_x + 1.05, peak_y - 0.45, "global peak", TextAnchor::Start)
        .hline(0.0, |h| h.stroke(Stroke::Dotted));

    std::fs::create_dir_all("out").expect("create out/");
    std::fs::write("out/annotated.svg", fig.to_svg()).expect("write svg");
    println!("wrote out/annotated.svg");
}