Struct plotpy::Shapes[][src]

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

Draw polygonal shapes

Example

// import
use plotpy::{Plot, Shapes};
use std::path::Path;

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

// shapes object and common options
let mut shapes = Shapes::new();
shapes.set_line_width(3.0).set_edge_color("#cd0000").set_face_color("#eeea83");

// draw arc
shapes.draw_arc(0.5, 0.5, 0.4, 195.0, -15.0);

// draw arrow
shapes.set_arrow_scale(50.0).set_arrow_style("fancy");
shapes.draw_arrow(0.4, 0.3, 0.6, 0.5);

// draw circle
shapes.set_face_color("None").set_edge_color("#1f9c25").set_line_width(6.0);
shapes.draw_circle(0.5, 0.5, 0.5);

// draw polyline
shapes.set_line_width(3.0).set_edge_color("blue");
let a = 0.2;
let c = f64::sqrt(3.0) / 2.0;
let p = vec![vec![0.1, 0.5], vec![0.1 + a, 0.5], vec![0.1 + a / 2.0, 0.5 + a * c]];
let q = vec![vec![0.9, 0.5], vec![0.9 - a, 0.5], vec![0.9 - a / 2.0, 0.5 + a * c]];
shapes.draw_polyline(&p, true);
shapes.draw_polyline(&q, false);

// add shapes to plot
let mut plot = Plot::new();
plot.set_hide_axes(true)
    .set_equal_axes()
    .set_range(-0.05, 1.05, -0.05, 1.05)
    .add(&shapes);

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

doc_shapes.svg

Implementations

Draws arc

Draws arrow

Draws circle

Draws polyline

Sets the edge color (shared among shapes)

Sets the face color (shared among shapes)

Sets the line width of edge (shared among shapes)

Sets the arrow scale

Sets the arrow style

Options:

  • -” – Curve : None
  • ->” – CurveB : head_length=0.4,head_width=0.2
  • -[” – BracketB : widthB=1.0,lengthB=0.2,angleB=None
  • -|>” – CurveFilledB : head_length=0.4,head_width=0.2
  • <-” – CurveA : head_length=0.4,head_width=0.2
  • <->” – CurveAB : head_length=0.4,head_width=0.2
  • <|-” – CurveFilledA : head_length=0.4,head_width=0.2
  • <|-|>” – CurveFilledAB : head_length=0.4,head_width=0.2
  • ]-” – BracketA : widthA=1.0,lengthA=0.2,angleA=None
  • ]-[” – BracketAB : widthA=1.0,lengthA=0.2,angleA=None,widthB=1.0,lengthB=0.2,angleB=None
  • fancy” – Fancy : head_length=0.4,head_width=0.4,tail_width=0.4
  • simple” – Simple : head_length=0.5,head_width=0.5,tail_width=0.2
  • wedge” – Wedge : tail_width=0.3,shrink_factor=0.5
  • |-|” – BarAB : widthA=1.0,angleA=None,widthB=1.0,angleB=None
  • As defined in https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyArrowPatch.html

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.