pub struct PositionJitter {
pub width: Option<f64>,
pub height: Option<f64>,
pub seed: u64,
}Expand description
Add random noise to x and y positions to reduce overplotting.
Each value moves by a uniform amount in [-width, width) (x) and
[-height, height) (y). None (the default) means “40% of the data’s
resolution”, as in ggplot2: the smallest gap between distinct values, or 1
for integer/constant data — so integer-coded categories (1, 2, 3, …) get
±0.4 and finely-spaced continuous data gets proportionally small noise.
Some(0.0) disables jitter along that axis.
Fields§
§width: Option<f64>Horizontal jitter amount in data units; None = 0.4 × resolution(x).
height: Option<f64>Vertical jitter amount in data units; None = 0.4 × resolution(y).
seed: u64Seed of the deterministic noise stream.
Implementations§
Source§impl PositionJitter
impl PositionJitter
Sourcepub fn new(width: f64, height: f64) -> Self
pub fn new(width: f64, height: f64) -> Self
Explicit jitter amounts (data units), default seed.
Sourcepub fn with_width(self, width: f64) -> Self
pub fn with_width(self, width: f64) -> Self
Set the horizontal jitter amount (data units).
Sourcepub fn with_height(self, height: f64) -> Self
pub fn with_height(self, height: f64) -> Self
Set the vertical jitter amount (data units).
Trait Implementations§
Source§impl Clone for PositionJitter
impl Clone for PositionJitter
Source§impl Debug for PositionJitter
impl Debug for PositionJitter
Source§impl Default for PositionJitter
impl Default for PositionJitter
Source§impl Position for PositionJitter
impl Position for PositionJitter
Source§fn per_panel(&self) -> bool
fn per_panel(&self) -> bool
ggplot2 4.0.3 measures position_jitter’s default width/height
(resolution(x) * 0.4) from each facet panel’s own x/y, not the
rows pooled across panels (#153) — verified with layer_data():
two panels with very different x spacing (e.g. integers vs.
hundredths) get differently-scaled jitter even under fixed facet
scales. The RNG draw is also per panel (it resets from seed at
the top of compute, as it already did), matching ggplot2’s own
per-panel restart — verified by the identical normalized jitter
fractions ggplot2 produces across panels for the same seed.
Source§fn compute(&self, data: &mut DataFrame, _params: &PositionParams)
fn compute(&self, data: &mut DataFrame, _params: &PositionParams)
fn name(&self) -> &str
Source§fn group_order(&self, _data: &DataFrame) -> Option<Vec<String>>
fn group_order(&self, _data: &DataFrame) -> Option<Vec<String>>
per_panel position whose group ranking must come
from the whole layer even though its per-x counting stays
per-panel (review #167 finding 2; sipemu/ggplot-rs#153).
build::compute_position_per_panel calls this on the pooled data
before splitting and threads the result through
PositionParams::group_order to every panel’s compute call.
Default None — positions that don’t need this (stack/fill/
jitter) are unaffected.Auto Trait Implementations§
impl Freeze for PositionJitter
impl RefUnwindSafe for PositionJitter
impl Send for PositionJitter
impl Sync for PositionJitter
impl Unpin for PositionJitter
impl UnsafeUnpin for PositionJitter
impl UnwindSafe for PositionJitter
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