pub struct Linspace<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>>{ /* private fields */ }
Expand description
The coordinate combinator that transform a continous coordinate to a discrete coordinate to a discrete coordinate by a giving step.
For example, range 0f32..100f32
is a continuous coordinate, thus this prevent us having a
histogram on it since Plotters doesn’t know how to segment the range into buckets.
In this case, to get a histogram, we need to split the original range to a
set of discrete buckets (for example, 0.5 per bucket).
The linspace decorate abstracting this method. For example, we can have a discrete coordinate:
(0f32..100f32).step(0.5)
.
Linspace also supports different types of bucket matching method - This configuration alters the behavior of DiscreteCoord::index_of for Linspace coord spec
- Flooring, the value falls into the nearst bucket smaller than it. See Linspace::use_floor
- Round, the value falls into the nearst bucket. See Linearspace::use_round
- Ceiling, the value falls into the nearst bucket larger than itself. See Linspace::use_ceil
- Exact Matchting, the value must be exactly same as the butcket value. See Linspace::use_exact
Implementations§
Source§impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Linspace<T, S, R>
impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Linspace<T, S, R>
Sourcepub fn use_ceil(self) -> Linspace<T, S, Ceil<T::ValueType>>
pub fn use_ceil(self) -> Linspace<T, S, Ceil<T::ValueType>>
Set the linspace use the round up method for value matching
- returns: The newly created linspace that uses new matching method
Sourcepub fn use_floor(self) -> Linspace<T, S, Floor<T::ValueType>>
pub fn use_floor(self) -> Linspace<T, S, Floor<T::ValueType>>
Set the linspace use the round down method for value matching
- returns: The newly created linspace that uses new matching method