Struct plotpy::Curve[][src]

pub struct Curve {
    pub label: String,
    pub line_alpha: f64,
    pub line_color: String,
    pub line_style: String,
    pub line_width: f64,
    pub marker_color: String,
    pub marker_every: i32,
    pub marker_void: bool,
    pub marker_line_color: String,
    pub marker_line_width: f64,
    pub marker_size: f64,
    pub marker_style: String,
    // some 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::*;
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, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0];

// configure and draw curve
let mut curve = Curve::new();
curve.label = "parabolic".to_string();
curve.line_alpha = 0.95;
curve.line_color = "#5f9cd8".to_string();
curve.line_style = "-".to_string();
curve.line_width = 5.0;
curve.marker_color = "#eeea83".to_string();
curve.marker_every = 1;
curve.marker_line_color = "#da98d1".to_string();
curve.marker_line_width = 2.5;
curve.marker_size = 20.0;
curve.marker_style = "*".to_string();
curve.draw(x, y);

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

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

doc_curve.svg

Fields

label: String

Label; name of this curve in the legend

line_alpha: f64

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

line_color: String

Color of lines

line_style: String

Style of lines

Options: “-”, :“, “--”, “-.”, or “None

As defined in https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html

line_width: f64

Width of lines

marker_color: String

Color of markers

marker_every: i32

Increment of data points to use when drawing markers

marker_void: bool

Draw a void marker (draw edge only)

marker_line_color: String

Edge color of markers

marker_line_width: f64

Edge width of markers

marker_size: f64

Size of markers

marker_style: String

Style of markers, e.g., “o”, “+

As defined in https://matplotlib.org/stable/api/markers_api.html

Implementations

Creates new Curve object

Draws curve

Input

  • x - abscissa values
  • y - ordinate values

Notes

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

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.