pub struct Text {
pub content: String,
pub font: String,
pub size: usize,
pub color: Rgb,
pub x: f64,
pub y: f64,
}Expand description
A structure representing text with customizable content, font, size, and color.
§Example
use polars::prelude::*;
use plotlars::{Axis, BarPlot, Plot, Text, Rgb};
let dataset = df![
"label" => &[""],
"value" => &[0],
]
.unwrap();
let axis = Axis::new()
.tick_values(vec![]);
BarPlot::builder()
.data(&dataset)
.labels("label")
.values("value")
.plot_title(
Text::from("Title")
.x(0.1)
.color(Rgb(178, 34, 34))
.size(30)
.font("Zapfino")
)
.x_title(
Text::from("X")
.color(Rgb(65, 105, 225))
.size(20)
.font("Marker Felt")
)
.y_title(
Text::from("Y")
.color(Rgb(255, 140, 0))
.size(20)
.font("Arial Black")
)
.x_axis(&axis)
.y_axis(&axis)
.build()
.plot();
Fields§
§content: String§font: String§size: usize§color: Rgb§x: f64§y: f64Implementations§
Source§impl Text
impl Text
Sourcepub fn from(content: impl Into<String>) -> Self
pub fn from(content: impl Into<String>) -> Self
Creates a new Text instance from the given content.
§Argument
content- A value that can be converted into aString, representing the textual content.
Sourcepub fn font(self, font: impl Into<String>) -> Self
pub fn font(self, font: impl Into<String>) -> Self
Sets the font of the text.
§Argument
font- A value that can be converted into aString, representing the font name.
Sourcepub fn x(self, x: f64) -> Self
pub fn x(self, x: f64) -> Self
Sets the x-coordinate position of the text.
§Argument
x- Af64value specifying the horizontal position.
Sourcepub fn y(self, y: f64) -> Self
pub fn y(self, y: f64) -> Self
Sets the y-coordinate position of the text.
§Argument
y- Af64value specifying the vertical position.
pub fn has_custom_position(&self) -> bool
Sourcepub fn with_plot_title_defaults(self) -> Self
pub fn with_plot_title_defaults(self) -> Self
Apply default positioning for plot titles (x=0.5, y=0.95 - centered above)
Sourcepub fn with_subplot_title_defaults(self) -> Self
pub fn with_subplot_title_defaults(self) -> Self
Apply default positioning for subplot titles (x=0.5, y=1.1 - centered above, higher than overall)
Sourcepub fn with_x_title_defaults(self) -> Self
pub fn with_x_title_defaults(self) -> Self
Apply default positioning for x-axis titles (x=0.5, y=-0.15 - centered below)
Sourcepub fn with_y_title_defaults(self) -> Self
pub fn with_y_title_defaults(self) -> Self
Apply default positioning for y-axis titles (x=-0.08, y=0.5 - left side, vertically centered)
Sourcepub fn with_x_title_defaults_for_annotation(self) -> Self
pub fn with_x_title_defaults_for_annotation(self) -> Self
Apply default positioning for x-axis title annotations Used when user sets custom position and annotation mode is triggered Ensures unset coordinates get appropriate axis defaults
Sourcepub fn with_y_title_defaults_for_annotation(self) -> Self
pub fn with_y_title_defaults_for_annotation(self) -> Self
Apply default positioning for y-axis title annotations Used when user sets custom position and annotation mode is triggered Ensures unset coordinates get appropriate axis defaults
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().