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)?;

doc_plot.svg

Implementations

Creates new Plot object

Adds new graph entity

Calls python3 and saves the python script and figure

Adds a title to the plot or sub-plot

Adds a title to all sub-plots

Configures subplots

Arguments

  • row - number of rows in the subplot grid
  • col - number of columns in the subplot grid
  • index - 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

Sets same scale for both axes

Hides axes

Sets axes limits

Sets x and y limits

Sets minimum x

Sets maximum x

Sets minimum y

Sets maximum y

Sets x-range (i.e. limits)

Sets y-range (i.e. limits)

Adds x-label

Adds y-label

Adds labels

Adds grid and labels

Clears current figure

Adds legend to plot (see Legend for further options)

Sets camera in 3d graph. Sets the elevation and azimuth of the axes.

Input

  • elev – is the elevation angle in the z plane
  • azimuth – is the azimuth angle in the x,y plane

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.