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(())
}
Implementations
sourceimpl Text
impl Text
sourcepub fn set_align_horizontal(&mut self, option: &str) -> &mut Self
pub fn set_align_horizontal(&mut self, option: &str) -> &mut Self
Sets the horizontal alignment
Options: “center”, “left”, “right”
sourcepub fn set_align_vertical(&mut self, option: &str) -> &mut Self
pub fn set_align_vertical(&mut self, option: &str) -> &mut Self
Sets the vertical alignment
Options: “center”, “top”, “bottom”, “baseline”, “center_baseline”
sourcepub fn set_fontsize(&mut self, fontsize: f64) -> &mut Self
pub fn set_fontsize(&mut self, fontsize: f64) -> &mut Self
Sets the font size
sourcepub fn set_rotation(&mut self, rotation: f64) -> &mut Self
pub fn set_rotation(&mut self, rotation: f64) -> &mut Self
Sets the text rotation
sourcepub fn set_bbox_facecolor(&mut self, color: &str) -> &mut Self
pub fn set_bbox_facecolor(&mut self, color: &str) -> &mut Self
Sets facecolor of bounding box
sourcepub fn set_bbox_edgecolor(&mut self, color: &str) -> &mut Self
pub fn set_bbox_edgecolor(&mut self, color: &str) -> &mut Self
Sets edgecolor of bounding box
sourcepub fn set_bbox_alpha(&mut self, value: f64) -> &mut Self
pub fn set_bbox_alpha(&mut self, value: f64) -> &mut Self
Sets alpha of bounding box
sourcepub fn set_bbox_style(&mut self, style: &str) -> &mut Self
pub fn set_bbox_style(&mut self, style: &str) -> &mut Self
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
sourceimpl GraphMaker for Text
impl GraphMaker for Text
fn get_buffer<'a>(&'a self) -> &'a String
Auto Trait Implementations
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more