use ruviz::plots::ContourInterpolation;
use ruviz::prelude::*;
fn main() -> Result<()> {
let size = 20;
let x: Vec<f64> = (0..size).map(|i| (i as f64 - 10.0) / 2.0).collect();
let y: Vec<f64> = (0..size).map(|i| (i as f64 - 10.0) / 2.0).collect();
let z: Vec<f64> = (0..size)
.flat_map(|j| {
(0..size).map(move |i| {
let xi = (i as f64 - 10.0) / 2.0;
let yj = (j as f64 - 10.0) / 2.0;
(-xi * xi - yj * yj).exp()
})
})
.collect();
Plot::new()
.title("Contour Plot")
.xlabel("X")
.ylabel("Y")
.contour(&x, &y, &z)
.levels(10)
.filled(true)
.smooth(ContourInterpolation::Cubic, 4) .colorbar(true)
.colorbar_label("Density")
.colormap_name("viridis")
.save("docs/assets/rustdoc/contour_plot.png")?;
println!("Generated docs/assets/rustdoc/contour_plot.png (high-level API)");
let levels: Vec<f64> = (0..10).map(|i| i as f64 / 10.0 + 0.05).collect();
Plot::new()
.title("Contour with Custom Levels")
.xlabel("X")
.ylabel("Y")
.contour(&x, &y, &z)
.level_values(levels)
.filled(true)
.smooth(ContourInterpolation::Linear, 4)
.colormap_name("plasma")
.save("docs/assets/rustdoc/contour_custom_levels.png")?;
println!("Generated docs/assets/rustdoc/contour_custom_levels.png");
Ok(())
}