use RustedSciThe::Utils::bevy_2d::{MultiPlotter, PlotColor};
use nalgebra::{DMatrix, DVector};
use std::collections::HashMap;
fn main() {
println!("Testing static function plotting with Bevy 2D...");
let n = 200;
let x = DVector::from_iterator(n, (0..n).map(|i| i as f64 * 0.05));
let mut ys = DMatrix::zeros(4, n);
for i in 0..n {
let xi = x[i];
ys[(0, i)] = xi.sin(); ys[(1, i)] = xi.cos(); ys[(2, i)] = 0.5 * (2.0 * xi).sin(); ys[(3, i)] = xi.exp() * 0.1; }
let names = vec![
"sin(x)".to_string(),
"cos(x)".to_string(),
"0.5*sin(2x)".to_string(),
"0.1*exp(x)".to_string(),
];
println!("Plotting {} functions with {} points each", names.len(), n);
println!("Use left mouse button to pan, scroll wheel to zoom");
let mut colors = HashMap::new();
colors.insert("sin(x)".to_string(), PlotColor::Red);
colors.insert("cos(x)".to_string(), PlotColor::DarkGreen);
colors.insert("0.5*sin(2x)".to_string(), PlotColor::Purple);
colors.insert("0.1*exp(x)".to_string(), PlotColor::Orange);
let plotter =
MultiPlotter {
subplot_height: 3.0, subplot_spacing: 4.0, nticks_x: 8, nticks_y: 6, axis_font_size: 14.0, line_width: 2.0, colors: Some(colors), x_axis_label: Some("Y".to_string()),
..Default::default()}; plotter
.plot_static_multiplot(x, ys, names);
}