pub struct Axis { /* private fields */ }Expand description
A structure representing a customizable axis.
§Example
use plotlars::{Axis, Plot, Rgb, ScatterPlot, Text, TickDirection};
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 axis = Axis::new()
.show_line(true)
.tick_direction(TickDirection::OutSide)
.value_thousands(true)
.show_grid(false);
ScatterPlot::builder()
.data(&dataset)
.x("body_mass_g")
.y("flipper_length_mm")
.group("species")
.colors(vec![
Rgb(255, 0, 0),
Rgb(0, 255, 0),
Rgb(0, 0, 255),
])
.opacity(0.5)
.size(20)
.plot_title(
Text::from("Scatter Plot")
.font("Arial")
.size(20)
.x(0.045)
)
.x_title("body mass (g)")
.y_title("flipper length (mm)")
.legend_title("species")
.x_axis(&axis)
.y_axis(&axis)
.build()
.plot();
Implementations§
Source§impl Axis
impl Axis
Sourcepub fn show_axis(self, bool: bool) -> Self
pub fn show_axis(self, bool: bool) -> Self
Sets the visibility of the axis.
§Argument
bool- A boolean value indicating whether the axis should be visible.
Sourcepub fn axis_side(self, side: AxisSide) -> Self
pub fn axis_side(self, side: AxisSide) -> Self
Sets the side of the axis.
§Argument
side- AnAxisSideenum value representing the side of the axis.
Sourcepub fn axis_position(self, position: f64) -> Self
pub fn axis_position(self, position: f64) -> Self
Sets the position of the axis.
§Argument
position- Af64value representing the position of the axis.
Sourcepub fn axis_type(self, axis_type: AxisType) -> Self
pub fn axis_type(self, axis_type: AxisType) -> Self
Sets the type of the axis.
§Argument
axis_type- AnAxisTypeenum value representing the type of the axis.
Sourcepub fn value_color(self, color: Rgb) -> Self
pub fn value_color(self, color: Rgb) -> Self
Sets the color of the axis values.
§Argument
color- AnRgbstruct representing the color of the axis values.
Sourcepub fn value_range(self, range: Vec<f64>) -> Self
pub fn value_range(self, range: Vec<f64>) -> Self
Sets the range of values displayed on the axis.
§Argument
range- A vector off64values representing the range of the axis.
Sourcepub fn value_thousands(self, bool: bool) -> Self
pub fn value_thousands(self, bool: bool) -> Self
Sets whether to use thousands separators for values.
§Argument
bool- A boolean value indicating whether to use thousands separators.
Sourcepub fn value_exponent(self, exponent: ValueExponent) -> Self
pub fn value_exponent(self, exponent: ValueExponent) -> Self
Sets the exponent format for values on the axis.
§Argument
exponent- AValueExponentenum value representing the exponent format.
Sourcepub fn tick_values(self, values: Vec<f64>) -> Self
pub fn tick_values(self, values: Vec<f64>) -> Self
Sets the tick values for the axis.
§Argument
values- A vector off64values representing the tick values.
Sourcepub fn tick_labels(self, labels: Vec<impl Into<String>>) -> Self
pub fn tick_labels(self, labels: Vec<impl Into<String>>) -> Self
Sets the tick labels for the axis.
§Argument
labels- A vector of values that can be converted intoString, representing the tick labels.
Sourcepub fn tick_direction(self, direction: TickDirection) -> Self
pub fn tick_direction(self, direction: TickDirection) -> Self
Sets the direction of the axis ticks.
§Argument
direction- ATickDirectionenum value representing the direction of the ticks.
Sourcepub fn tick_length(self, length: usize) -> Self
pub fn tick_length(self, length: usize) -> Self
Sets the length of the axis ticks.
§Argument
length- Ausizevalue representing the length of the ticks.
Sourcepub fn tick_width(self, width: usize) -> Self
pub fn tick_width(self, width: usize) -> Self
Sets the width of the axis ticks.
§Argument
width- Ausizevalue representing the width of the ticks.
Sourcepub fn tick_color(self, color: Rgb) -> Self
pub fn tick_color(self, color: Rgb) -> Self
Sets the color of the axis ticks.
§Argument
color- AnRgbstruct representing the color of the ticks.
Sourcepub fn tick_angle(self, angle: f64) -> Self
pub fn tick_angle(self, angle: f64) -> Self
Sets the angle of the axis ticks.
§Argument
angle- Af64value representing the angle of the ticks in degrees.
Sourcepub fn tick_font(self, font: impl Into<String>) -> Self
pub fn tick_font(self, font: impl Into<String>) -> Self
Sets the font of the axis tick labels.
§Argument
font- A value that can be converted into aString, representing the font name for the tick labels.
Sourcepub fn show_line(self, bool: bool) -> Self
pub fn show_line(self, bool: bool) -> Self
Sets whether to show the axis line.
§Argument
bool- A boolean value indicating whether the axis line should be visible.
Sourcepub fn line_color(self, color: Rgb) -> Self
pub fn line_color(self, color: Rgb) -> Self
Sets the color of the axis line.
§Argument
color- AnRgbstruct representing the color of the axis line.
Sourcepub fn line_width(self, width: usize) -> Self
pub fn line_width(self, width: usize) -> Self
Sets the width of the axis line.
§Argument
width- Ausizevalue representing the width of the axis line.
Sourcepub fn show_grid(self, bool: bool) -> Self
pub fn show_grid(self, bool: bool) -> Self
Sets whether to show the grid lines on the axis.
§Argument
bool- A boolean value indicating whether the grid lines should be visible.
Sourcepub fn grid_color(self, color: Rgb) -> Self
pub fn grid_color(self, color: Rgb) -> Self
Sets the color of the grid lines on the axis.
§Argument
color- AnRgbstruct representing the color of the grid lines.
Sourcepub fn grid_width(self, width: usize) -> Self
pub fn grid_width(self, width: usize) -> Self
Sets the width of the grid lines on the axis.
§Argument
width- Ausizevalue representing the width of the grid lines.
Sourcepub fn show_zero_line(self, bool: bool) -> Self
pub fn show_zero_line(self, bool: bool) -> Self
Sets whether to show the zero line on the axis.
§Argument
bool- A boolean value indicating whether the zero line should be visible.
Sourcepub fn zero_line_color(self, color: Rgb) -> Self
pub fn zero_line_color(self, color: Rgb) -> Self
Sets the color of the zero line on the axis.
§Argument
color- AnRgbstruct representing the color of the zero line.
Sourcepub fn zero_line_width(self, width: usize) -> Self
pub fn zero_line_width(self, width: usize) -> Self
Sets the width of the zero line on the axis.
§Argument
width- Ausizevalue representing the width of the zero line.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Axis
impl RefUnwindSafe for Axis
impl Send for Axis
impl Sync for Axis
impl Unpin for Axis
impl UnwindSafe for Axis
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().