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)?;
Implementations
Horizontal alignment: “center”, “left”, “right”
Vertical alignment: “center”, “top”, “bottom”, “baseline”, “center_baseline”
Font size
Text rotation