basic_scatter/
basic_scatter.rs1use esoc_chart::v2::scatter;
5
6fn main() -> esoc_chart::error::Result<()> {
7 let x: Vec<f64> = (0..50).map(|i| f64::from(i) * 0.2).collect();
9 let y: Vec<f64> = x
10 .iter()
11 .map(|&xi| xi * xi + ((xi * 7.0).sin()) * 1.5)
12 .collect();
13
14 let svg = scatter(&x, &y)
15 .title("y = x² + noise")
16 .x_label("x")
17 .y_label("y")
18 .to_svg()?;
19
20 std::fs::write("basic_scatter.svg", &svg)?;
21 println!("Saved basic_scatter.svg ({} bytes)", svg.len());
22 Ok(())
23}