Crate plotpy[−][src]
Expand description
Rust plotting library using Python (Matplotlib)
This library generates plots by calling python3 after generating a python script. The name of the python script is based on the name of the figure (png, svg, …). If an error occurs, a log file is created (also named as the figure).
The main idea here is to create objects such as Curve
, Contour
, Histogram
,
or Surface
and add it to a plot using the add
command. The plot may
also configured using the methods of Plot
.
Each object (e.g. Curve
, Legend
, Text
) defines a number of configuration options
that can be directly set on the object. Then, the draw
method of each object must
be called before adding to Plot
.
Example
use russell_lab::generate3d;
let mut surface = Surface::new();
surface
.set_with_wireframe(true)
.set_colormap_name("Pastel1")
.set_with_colorbar(true)
.set_colorbar_label("temperature")
.set_line_color("#1862ab")
.set_line_style(":")
.set_line_width(0.75);
// draw surface
let n = 9;
let (x, y, z) = generate3d(-2.0, 2.0, -2.0, 2.0, n, n, |x, y| x * x + y * y);
surface.draw(&x, &y, &z);
// add surface to plot
let mut plot = Plot::new();
plot.add(&surface);
// save figure
plot.save(Path::new("/tmp/plotpy/example_main.svg"))?;
Structs
Generates a contour plot
Generates a curve (aka line-plot) given two arrays (x,y)
Generates a Histogram plot
Generates a Legend
Driver structure that calls Python
Draw polygonal shapes
Generates a 3D a surface (or wireframe, or both)
Creates text to be added to a plot
Constants
Traits
Defines a trait to handle Matrix-like data
Defines a trait to handle Vector-like data