use plt::*; fn main() { // create data let xs: Vec = (0..=100).map(|n: u32| n as f64 / 100.0).collect(); let y1s: Vec = xs.iter().map(|x| x.powi(3)).collect(); let y2s: Vec = y1s.iter().map(|y| *y * 20.0).rev().collect(); // create subplot let mut sp = Subplot::builder() .title("double plot") .label(Axes::X, "x data") .label(Axes::Y, "y1 data") .label(Axes::SecondaryY, "y2 data") .build(); // plot data on primary y-axis sp.plot(&xs, &y1s).unwrap(); // plot data on secondary y-axis sp.plotter() .use_secondary_yaxis() .plot(&xs, &y2s) .unwrap(); // make figure and add subplot let mut fig =
::default(); fig.set_layout(SingleLayout::new(sp)).unwrap(); // save figure to file fig.draw_file(FileFormat::Png, "example.png").unwrap(); }