Struct plotpy::Text[][src]

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

Creates text to be added to a plot

Example

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

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

// configure and draw text
let mut text = Text::new();
text.set_color("#cd0000")
    .set_align_horizontal("center")
    .set_align_vertical("center")
    .set_fontsize(30.0)
    .set_rotation(45.0);
text.draw(0.0, 0.0, "Hello World!");

// add text to plot
let mut plot = Plot::new();
plot.add(&text)
    .set_range(-1.0, 1.0, -1.0, 1.0)
    .set_hide_axes(true);

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

doc_text.svg

Implementations

Creates a new Text object

Draws text

Color

Horizontal alignment: “center”, “left”, “right”

Vertical alignment: “center”, “top”, “bottom”, “baseline”, “center_baseline”

Font size

Text rotation

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.