pub struct AxisHints { /* private fields */ }
Expand description
Axis configuration.
Used to configure axis label and ticks.
Implementations§
source§impl AxisHints
impl AxisHints
sourcepub fn new(axis: Axis) -> Self
pub fn new(axis: Axis) -> Self
Initializes a default axis configuration for the specified axis.
label
is empty.
formatter
is default float to string formatter.
maximum digits
on tick label is 5.
sourcepub fn formatter(
self,
fmt: impl Fn(GridMark, usize, &RangeInclusive<f64>) -> String + 'static
) -> Self
pub fn formatter( self, fmt: impl Fn(GridMark, usize, &RangeInclusive<f64>) -> String + 'static ) -> Self
Specify custom formatter for ticks.
The first parameter of formatter
is the raw tick value as f64
.
The second parameter is the maximum number of characters that fit into y-labels.
The second parameter of formatter
is the currently shown range on this axis.
sourcepub fn label(self, label: impl Into<WidgetText>) -> Self
pub fn label(self, label: impl Into<WidgetText>) -> Self
Specify axis label.
The default is ‘x’ for x-axes and ‘y’ for y-axes.
sourcepub fn max_digits(self, digits: usize) -> Self
pub fn max_digits(self, digits: usize) -> Self
Specify maximum number of digits for ticks.
This is considered by the default tick formatter and affects the width of the y-axis
sourcepub fn placement(self, placement: impl Into<Placement>) -> Self
pub fn placement(self, placement: impl Into<Placement>) -> Self
Specify the placement of the axis.
For X-axis, use VPlacement
.
For Y-axis, use HPlacement
.
sourcepub fn label_spacing(self, range: impl Into<Rangef>) -> Self
pub fn label_spacing(self, range: impl Into<Rangef>) -> Self
Set the minimum spacing between labels
When labels get closer together than the given minimum, then they become invisible. When they get further apart than the max, they are at full opacity.
Labels can never be closer together than the crate::Plot::grid_spacing
setting.