pub fn quick_plot_multi(
series: &[(&[f64], &[f64])],
title: Option<&str>,
x_label: Option<&str>,
y_label: Option<&str>,
width: usize,
height: usize,
) -> StringExpand description
Quick one-shot plot of multiple line series. Returns the rendered string.
This is a convenience wrapper over the Figure/Axes2D API.
ยงExamples
let xs: Vec<f64> = (0..=10).map(|i| i as f64).collect();
let ys1: Vec<f64> = xs.iter().map(|x| x * x).collect();
let ys2: Vec<f64> = xs.iter().map(|x| x * 2.0).collect();
let output = ploot::quick_plot_multi(
&[(&xs, &ys1), (&xs, &ys2)],
Some("Two series"),
Some("x"),
Some("y"),
60,
15,
);
assert!(output.contains("Two series"));Examples found in repository?
examples/multi_series.rs (lines 8-20)
1fn main() {
2 let xs: Vec<f64> = (-30..=30).map(|i| i as f64 / 10.0).collect();
3 let quadratic: Vec<f64> = xs.iter().map(|&x| x * x).collect();
4 let cubic: Vec<f64> = xs.iter().map(|&x| x * x * x).collect();
5 let sine: Vec<f64> = xs.iter().map(|&x| 8.0 * (x * 1.5).sin()).collect();
6 let gaussian: Vec<f64> = xs.iter().map(|&x| 20.0 * (-x * x).exp()).collect();
7
8 let plot = ploot::quick_plot_multi(
9 &[
10 (&xs, &quadratic),
11 (&xs, &cubic),
12 (&xs, &sine),
13 (&xs, &gaussian),
14 ],
15 Some("x^2 vs x^3 vs 8*sin(1.5x) vs 20*e^(-x^2)"),
16 Some("x"),
17 Some("y"),
18 80,
19 24,
20 );
21 println!("{plot}");
22}