pub struct Legend { /* private fields */ }Expand description
A structure representing a customizable plot legend.
§Example
use plotlars::{Histogram, Legend, Orientation, Plot, Rgb};
let dataset = LazyCsvReader::new("data/penguins.csv")
.finish()
.unwrap()
.select([
col("species"),
col("sex").alias("gender"),
col("flipper_length_mm").cast(DataType::Int16),
col("body_mass_g").cast(DataType::Int16),
])
.collect()
.unwrap();
let legend = Legend::new()
.orientation(Orientation::Horizontal)
.border_width(1)
.x(0.78)
.y(0.825);
Histogram::builder()
.data(&dataset)
.x("body_mass_g")
.group("species")
.colors(vec![
Rgb(255, 0, 0),
Rgb(0, 255, 0),
Rgb(0, 0, 255),
])
.opacity(0.5)
.x_title("Body Mass (g)")
.y_title("Frequency")
.legend_title("Species")
.legend(&legend)
.build()
.plot();
Implementations§
Source§impl Legend
impl Legend
Sourcepub fn background_color(self, color: Rgb) -> Self
pub fn background_color(self, color: Rgb) -> Self
Sets the background color of the legend.
§Argument
color- AnRgbstruct representing the background color.
Sourcepub fn border_color(self, color: Rgb) -> Self
pub fn border_color(self, color: Rgb) -> Self
Sourcepub fn border_width(self, width: usize) -> Self
pub fn border_width(self, width: usize) -> Self
Sets the border width of the legend.
§Argument
width- Ausizevalue representing the width of the border.
Sourcepub fn font(self, font: impl Into<String>) -> Self
pub fn font(self, font: impl Into<String>) -> Self
Sets the font of the legend labels.
§Argument
font- A value that can be converted into aString, representing the font name for the labels.
Sourcepub fn orientation(self, orientation: Orientation) -> Self
pub fn orientation(self, orientation: Orientation) -> Self
Sets the orientation of the legend.
§Argument
orientation- AnOrientationenum value representing the layout direction of the legend.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Legend
impl RefUnwindSafe for Legend
impl Send for Legend
impl Sync for Legend
impl Unpin for Legend
impl UnwindSafe for Legend
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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> Pointable for T
impl<T> Pointable for T
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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().