pub struct SecAxis {
pub transform: fn(f64) -> f64,
pub name: String,
pub breaks: Option<Vec<f64>>,
pub percent_of_max: bool,
}Expand description
A secondary axis specification — defines a transformation from the primary axis domain.
§Example
use ggplot_rs::prelude::*;
// Temperature in Celsius on primary, Fahrenheit on secondary
let sec = SecAxis::new(|c| c * 9.0 / 5.0 + 32.0).with_name("Fahrenheit");Fields§
§transform: fn(f64) -> f64Transformation from primary axis values to secondary axis values.
name: StringName / title for the secondary axis.
breaks: Option<Vec<f64>>Custom break positions in primary axis coordinates.
percent_of_max: boolLabel the axis as a percentage of the primary scale’s trained data
maximum (SecAxis::percent_of_max) instead of through transform.
Implementations§
Source§impl SecAxis
impl SecAxis
Sourcepub fn new(transform: fn(f64) -> f64) -> Self
pub fn new(transform: fn(f64) -> f64) -> Self
Create a secondary axis with the given transformation function.
Sourcepub fn percent_of_max() -> Self
pub fn percent_of_max() -> Self
A 0–100 % axis relative to the primary scale’s trained data maximum (the value drawn at the right axis’ 100 % tick) — e.g. a Pareto chart’s cumulative share, where the maximum is the grand total. The ticks sit at their own nice percentages (0, 25, …, 100 %) rather than at the primary breaks.
pub fn with_name(self, name: &str) -> Self
pub fn with_breaks(self, breaks: Vec<f64>) -> Self
Sourcepub fn transform_value(&self, v: f64) -> f64
pub fn transform_value(&self, v: f64) -> f64
Transform a primary axis value to the secondary axis value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecAxis
impl RefUnwindSafe for SecAxis
impl Send for SecAxis
impl Sync for SecAxis
impl Unpin for SecAxis
impl UnsafeUnpin for SecAxis
impl UnwindSafe for SecAxis
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> 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 more