Struct plotpy::Text [−][src]
pub struct Text {
pub color: String,
pub align_horizontal: String,
pub align_vertical: String,
pub font_size: f64,
pub rotation: f64,
// some fields omitted
}
Expand description
Creates text to be added to a plot
Example
// import
use plotpy::*;
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.color = "#cd0000".to_string();
text.align_horizontal = "center".to_string();
text.align_vertical = "center".to_string();
text.font_size = 30.0;
text.rotation = 45.0;
text.draw(0.0, 0.0, "Hello World!");
// add text to plot
let mut plot = Plot::new();
plot.add(&text);
plot.range(-1.0, 1.0, -1.0, 1.0);
plot.hide_axes();
// save figure
let path = Path::new(OUT_DIR).join("doc_text.svg");
plot.save(&path)?;
Fields
color: String
Color
align_horizontal: String
Horizontal alignment: “center”, “left”, “right”
align_vertical: String
Vertical alignment: “center”, “top”, “bottom”, “baseline”, “center_baseline”
font_size: f64
Font size
rotation: f64
Text rotation