use bland::{multi_panel, Figure, Marker, PanelGridOpts, Stroke};
fn main() {
let xs: Vec<f64> = (0..=100).map(|i| i as f64 / 10.0).collect();
let response: Vec<f64> = xs.iter().map(|t| (-t / 4.0).exp() * t.cos()).collect();
let envelope: Vec<f64> = xs.iter().map(|t| (-t / 4.0).exp()).collect();
let panel_a = Figure::new()
.dimensions(800.0, 500.0)
.title("Panel A — response")
.xlabel("t [s]")
.ylabel("x(t)")
.line(&xs, &response, |s| s.label("x(t)"));
let panel_b = Figure::new()
.dimensions(800.0, 500.0)
.title("Panel B — envelope")
.xlabel("t [s]")
.ylabel("|x(t)|")
.line(&xs, &envelope, |s| {
s.label("envelope").stroke(Stroke::Dashed).marker(Marker::CircleOpen)
});
let svg = multi_panel(
&[panel_a, panel_b],
PanelGridOpts::default()
.columns(2)
.cell_size(800.0, 500.0)
.title("Damped oscillation — overview"),
);
std::fs::create_dir_all("out").expect("create out/");
std::fs::write("out/panels.svg", svg).expect("write svg");
println!("wrote out/panels.svg");
}