Struct plotpy::Plot [−][src]
pub struct Plot { /* fields omitted */ }
Expand description
Driver structure that calls Python
Example
// import
use plotpy::*;
use std::path::Path;
// directory to save figures
const OUT_DIR: &str = "/tmp/plotpy/doc_tests";
// generate (x,y) points
let x = &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
let y = &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
// configure and draw curve
let mut curve = Curve::new();
curve.label = "line".to_string();
curve.draw(x, y);
// configure plot
let mut plot = Plot::new();
plot.title_all_subplots("four views of the same curve");
plot.subplot_vertical_gap(0.50);
// add curve to subplot
plot.subplot(2, 2, 1);
plot.title("first");
plot.add(&curve);
plot.legend();
plot.grid_and_labels("x", "y");
// add curve to subplot
plot.subplot(2, 2, 2);
plot.title("second");
plot.add(&curve);
plot.legend();
plot.grid_and_labels("x", "y");
// add curve to subplot
plot.subplot(2, 2, 3);
plot.title("third");
plot.add(&curve);
plot.legend();
plot.grid_and_labels("x", "y");
// add curve to subplot
plot.subplot(2, 2, 4);
plot.title("fourth");
plot.add(&curve);
plot.grid_and_labels("x", "y");
plot.equal();
plot.legend();
plot.xrange(2.0, 8.0);
plot.yrange(2.0, 8.0);
// save figure
let path = Path::new(OUT_DIR).join("doc_plot.svg");
plot.save(&path)?;
Implementations
Adds new graph entity
Calls python3 and saves the python script and figure
Adds a title to all sub-plots
Configures subplots
Arguments
row
- number of rows in the subplot gridcol
- number of columns in the subplot gridindex
- activate current subplot; indices start at one [1-based]
Sets the horizontal gap between subplots
Sets the vertical gap between subplots
Sets the horizontal and vertical gap between subplots
Adds grid and labels
Clears current figure