pub struct SecAxis {
pub transform: fn(f64) -> f64,
pub name: String,
pub breaks: Option<Vec<f64>>,
pub percent_of_max: bool,
pub linear: Option<(f64, f64)>,
pub labeller: Option<SecLabeller>,
}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.
linear: Option<(f64, f64)>secondary = primary * scale + offset (SecAxis::linear): the
axis gets its own nice ticks in the secondary range.
labeller: Option<SecLabeller>Formats the secondary axis’ tick values (SecAxis::with_labeller);
None uses the plot’s number format.
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.
Sourcepub fn linear(scale: f64, offset: f64) -> Self
pub fn linear(scale: f64, offset: f64) -> Self
A linear secondary axis: secondary = primary * scale + offset,
e.g. a second measure drawn rescaled into the primary range (a
combo chart’s right axis). Its ticks sit at nice values of the
secondary range, not at the primary breaks. A zero or non-finite
scale falls back to the identity.
Sourcepub fn with_labeller(
self,
f: impl Fn(f64) -> String + Send + Sync + 'static,
) -> Self
pub fn with_labeller( self, f: impl Fn(f64) -> String + Send + Sync + 'static, ) -> Self
Format the secondary axis’ tick labels with f (e.g. a currency or
percent format of the second measure).
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 !RefUnwindSafe for SecAxis
impl !UnwindSafe for SecAxis
impl Freeze for SecAxis
impl Send for SecAxis
impl Sync for SecAxis
impl Unpin for SecAxis
impl UnsafeUnpin 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