Struct plotpy::Shapes [−][src]
pub struct Shapes {
pub edge_color: String,
pub face_color: String,
pub line_width: f64,
pub arrow_scale: f64,
pub arrow_style: String,
// some fields omitted
}
Expand description
Draw polygonal shapes
Example
// import
use plotpy::*;
use std::path::Path;
// directory to save figures
const OUT_DIR: &str = "/tmp/plotpy/doc_tests";
// shapes object and options
let mut shapes = Shapes::new();
shapes.line_width = 3.0;
shapes.edge_color = "#cd0000".to_string();
shapes.face_color = "#eeea83".to_string();
// draw arc
shapes.arc(0.5, 0.5, 0.4, 195.0, -15.0);
// draw arrow
shapes.arrow_scale = 50.0;
shapes.arrow_style = "fancy".to_string();
shapes.arrow(0.4, 0.3, 0.6, 0.5);
// draw circle
shapes.face_color = "None".to_string();
shapes.edge_color = "#1f9c25".to_string();
shapes.line_width = 6.0;
shapes.circle(0.5, 0.5, 0.5);
// draw polyline
shapes.line_width = 3.0;
shapes.edge_color = "blue".to_string();
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.polyline(&p, true);
shapes.polyline(&q, false);
// add shapes to plot
let mut plot = Plot::new();
plot.hide_axes();
plot.equal();
plot.range(-0.05, 1.05, -0.05, 1.05);
plot.add(&shapes);
// save figure
let path = Path::new(OUT_DIR).join("doc_shapes.svg");
plot.save(&path)?;
Fields
edge_color: String
Edge color (shared)
face_color: String
Face color (shared)
line_width: f64
Line width of edge (shared)
arrow_scale: f64
Arrow scale
arrow_style: String
Arrow style
- “
-
” – 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
Implementations
Draws arc