Crate plotpy[][src]

Expand description

Rust plotting library using Python (Matplotlib)

Examples

use plotpy::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let x = &[1.0, 2.0, 3.0, 4.0, 5.0];
    let y = &[1.0, 4.0, 9.0, 16.0, 25.0];
    let mut curve = Curve::new();
    curve.draw(x, y);

    let mut plot = Plot::new();
    plot.subplot(2, 2, 1);
    plot.add(&curve);

    plot.subplot(2, 2, 2);
    plot.add(&curve);

    plot.subplot(2, 2, 3);
    plot.add(&curve);

    plot.subplot(2, 2, 4);
    plot.add(&curve);
    plot.grid_and_labels("x", "y");

    let message = plot.save("/tmp/plotpy", "example_main", "svg")?;
    println!("{}", message);
    Ok(())
}

example_main.svg

Todo

  • Test Contour
  • Test Graphs3d
  • Test Histogram
  • Test Legend
  • Test Shapes
  • Test Text

Structs

Generates a contour plot

Generates a curve (aka line-plot) given two arrays (x,y)

Generates a 3D graph: surface or wireframe, or both

Generates a Histogram plot

Creates a legend to be added to the plot

Driver structure that calls Python

Generates scatter plot given two arrays (x,y)

Draw polygonal shapes

Creates text to be added to a plot

Constants

Traits