Struct plotpy::Text

source · []
pub struct Text { /* private fields */ }
Expand description

Creates text to be added to a plot

Example

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

fn main() -> Result<(), StrError> {
    // configure text
    let mut text = Text::new();
    text.set_color("purple")
        .set_align_horizontal("center")
        .set_align_vertical("center")
        .set_fontsize(30.0)
        .set_rotation(45.0)
        .set_bbox(true)
        .set_bbox_facecolor("pink")
        .set_bbox_edgecolor("black")
        .set_bbox_alpha(0.3)
        .set_bbox_style("roundtooth,pad=0.3,tooth_size=0.2");

    // draw text
    text.draw_3d(0.5, 0.5, 0.5, "Hello World!");

    // add text to plot
    let mut plot = Plot::new();
    plot.add(&text);

    // save figure
    plot.save("/tmp/plotpy/doc_tests/doc_text.svg")?;
    Ok(())
}

doc_text.svg

Implementations

Creates a new Text object

Draws text

Draws text in 3D plot

Sets the text color

Sets the horizontal alignment

Options: “center”, “left”, “right”

Sets the vertical alignment

Options: “center”, “top”, “bottom”, “baseline”, “center_baseline”

Sets the font size

Sets the text rotation

Sets use bounding box flag

Sets facecolor of bounding box

Sets edgecolor of bounding box

Sets alpha of bounding box

Sets style of bounding box; example

Examples:

  • “square,pad=0.3”
  • “circle,pad=0.3”
  • “larrow,pad=0.3”
  • “rarrow,pad=0.3”
  • “darrow,pad=0.3”
  • “round,pad=0.3,rounding_size=0.15”
  • “round4,pad=0.3,rounding_size=0.2”
  • “sawtooth,pad=0.3,tooth_size=0.1”
  • “roundtooth,pad=0.3,tooth_size=0.2”

See Matplotlib

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.