pub struct Linspace<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone, { /* 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
sourceimpl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
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
Trait Implementations
sourceimpl<T: Clone + Ranged, S: Clone + Clone, R: Clone + LinspaceRoundingMethod<T::ValueType>> Clone for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
T::ValueType: Clone,
impl<T: Clone + Ranged, S: Clone + Clone, R: Clone + LinspaceRoundingMethod<T::ValueType>> Clone for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
T::ValueType: Clone,
sourceimpl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> DiscreteRanged for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> DiscreteRanged for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
sourcefn size(&self) -> usize
fn size(&self) -> usize
Get the number of element in the range Note: we assume that all the ranged discrete coordinate has finite value Read more
sourcefn from_index(&self, idx: usize) -> Option<T::ValueType>
fn from_index(&self, idx: usize) -> Option<T::ValueType>
Reverse map the index to the value Read more
sourcefn values(&self) -> DiscreteValueIter<'_, Self> where
Self: Sized,
fn values(&self) -> DiscreteValueIter<'_, Self> where
Self: Sized,
Return a iterator that iterates over the all possible values Read more
sourceimpl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Ranged for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
impl<T: Ranged, S: Clone, R: LinspaceRoundingMethod<T::ValueType>> Ranged for Linspace<T, S, R> where
T::ValueType: Add<S, Output = T::ValueType> + PartialOrd + Clone,
type FormatOption = NoDefaultFormatting
type FormatOption = NoDefaultFormatting
This marker decides if Plotters default ValueFormatter implementation should be used. This associated type can be one of the following two types: Read more
sourcefn map(&self, value: &T::ValueType, limit: (i32, i32)) -> i32
fn map(&self, value: &T::ValueType, limit: (i32, i32)) -> i32
This function maps the value to i32, which is the drawing coordinate
sourcefn key_points<Hint: KeyPointHint>(&self, hint: Hint) -> Vec<T::ValueType>
fn key_points<Hint: KeyPointHint>(&self, hint: Hint) -> Vec<T::ValueType>
This function gives the key points that we can draw a grid based on this
sourceimpl<T, R, S, RM> ValueFormatter<T> for Linspace<R, S, RM> where
R: Ranged<ValueType = T> + ValueFormatter<T>,
RM: LinspaceRoundingMethod<T>,
T: Add<S, Output = T> + PartialOrd + Clone,
S: Clone,
impl<T, R, S, RM> ValueFormatter<T> for Linspace<R, S, RM> where
R: Ranged<ValueType = T> + ValueFormatter<T>,
RM: LinspaceRoundingMethod<T>,
T: Add<S, Output = T> + PartialOrd + Clone,
S: Clone,
Auto Trait Implementations
impl<T, S, R> RefUnwindSafe for Linspace<T, S, R> where
R: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
<T as Ranged>::ValueType: RefUnwindSafe,
impl<T, S, R> Send for Linspace<T, S, R> where
R: Send,
S: Send,
T: Send,
<T as Ranged>::ValueType: Send,
impl<T, S, R> Sync for Linspace<T, S, R> where
R: Sync,
S: Sync,
T: Sync,
<T as Ranged>::ValueType: Sync,
impl<T, S, R> Unpin for Linspace<T, S, R> where
R: Unpin,
S: Unpin,
T: Unpin,
<T as Ranged>::ValueType: Unpin,
impl<T, S, R> UnwindSafe for Linspace<T, S, R> where
R: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
<T as Ranged>::ValueType: UnwindSafe,
Blanket Implementations
sourceimpl<T> AsRangedCoord for T where
T: Ranged,
impl<T> AsRangedCoord for T where
T: Ranged,
type CoordDescType = T
type CoordDescType = T
Type to describe a coordinate system
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more