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};

fn main() {
    // 41×41 grid of sin(x) · cos(y) over [-π, π]².
    let n = 41;
    let pi = std::f64::consts::PI;
    let grid: Vec<Vec<f64>> = (0..n)
        .map(|j| {
            let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
            (0..n)
                .map(|i| {
                    let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
                    x.sin() * y.cos()
                })
                .collect()
        })
        .collect();

    let edges: Vec<f64> = (0..=n)
        .map(|i| -pi + 2.0 * pi * i as f64 / n as f64)
        .collect();

    let levels = vec![-0.8, -0.4, 0.0, 0.4, 0.8];

    let fig = Figure::new()
        .size(PaperSize::Square)
        .title("sin(x) · cos(y)")
        .xlabel("x")
        .ylabel("y")
        .contour(grid, |c| {
            c.x_edges(edges.clone())
                .y_edges(edges.clone())
                .levels(levels)
                .label("isolines")
        })
        .legend_top_right();

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