Struct plotpy::Curve[][src]

pub struct Curve { /* fields omitted */ }
Expand description

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

Notes

  • This struct corresponds to the plot function of Matplotlib.
  • You may plot a Scatter plot by setting line_style = “None”

Example

// import
use plotpy::{Curve, Plot};
use russell_lab::Vector;
use std::path::Path;

// directory to save figures
const OUT_DIR: &str = "/tmp/plotpy/doc_tests";

// generate (x,y) points
let x = Vector::linspace(-1.0, 1.0, 21);
let y = x.get_mapped(|v| 1.0 / (1.0 + f64::exp(-5.0 * v)));

// configure curve
let mut curve = Curve::new();
curve.set_label("logistic function")
    .set_line_alpha(0.8)
    .set_line_color("#5f9cd8")
    .set_line_style("-")
    .set_line_width(5.0)
    .set_marker_color("#eeea83")
    .set_marker_every(5)
    .set_marker_line_color("#da98d1")
    .set_marker_line_width(2.5)
    .set_marker_size(20.0)
    .set_marker_style("*");

// draw curve
curve.draw(&x, &y);

// add curve to plot
let mut plot = Plot::new();
plot.add(&curve)
    .set_num_ticks_y(11)
    .grid_labels_legend("x", "y");

// save figure
let path = Path::new(OUT_DIR).join("doc_curve.svg");
plot.save(&path)?;

doc_curve.svg

Implementations

Creates new Curve object

Draws curve

Input

  • x - abscissa values
  • y - ordinate values

Notes

  • The type U of the input array must be a number.

Sets the name of this curve in the legend

Sets the opacity of lines (0, 1]. A<1e-14 => A=1.0

Sets the color of lines

Sets the style of lines

Options:

Sets the width of lines

Sets the color of markers

Sets the increment of data points to use when drawing markers

Sets the option to draw a void marker (draw edge only)

Sets the edge color of markers

Sets the edge width of markers

Sets the size of markers

Sets the style of markers

Examples:

Trait Implementations

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.