Skip to main content

ElementGeom

Struct ElementGeom 

Source
#[non_exhaustive]
pub struct ElementGeom { pub ink: Option<(u8, u8, u8)>, pub paper: Option<(u8, u8, u8)>, pub accent: Option<(u8, u8, u8)>, pub family: Option<String>, }
Expand description

Geom “ink”/“paper”/“accent” palette (ggplot2 4.0’s element_geom, B2-7): recolours a geom’s built-in default colour without touching every geom’s own color/fill field or needing a mapped/explicit colour to be set first. None everywhere (the default) changes nothing — byte-identical output. Marked #[non_exhaustive] so a later field can be added without an ..Default::default() break.

A default Geom::apply_element_geom is a no-op; a geom that honours this overrides it, replacing only fields still at their own built-in default — called once per layer, before the brand Theme::primary colour is applied, and (like the brand colour) only for a layer that was not configured explicitly via geom_*_with(...): that is the actual guard against touching an explicit colour (an explicit_style gate in the build pipeline), not a comparison of the field’s value against the hard-coded default, which can’t otherwise tell an explicitly-set black apart from a black nobody touched.

Geoms covered: GeomPoint, GeomLine, GeomPath, GeomText, GeomLabel, GeomBoxplot, GeomSegment, GeomCurve, the reference lines (GeomHline/GeomVline/GeomAbline), GeomErrorbar/ GeomErrorbarh/GeomLinerange/GeomPointrange, GeomStep, the outline colour of GeomRect/GeomTile/GeomBar/GeomCol/ GeomPolygon/GeomViolin/GeomDensity/GeomArea/GeomCount/ GeomHex/GeomContour/GeomHistogram/GeomDensity2d/GeomBin2d/ GeomSf (feature sf), GeomCrossbar, GeomTextRepel, GeomLabelRepel, GeomSpoke, GeomRug, GeomBracket, GeomJitter, GeomQQ, GeomCensorMarks and GeomFreqpoly (ink for a black/ (50, 50, 50) line, text or outline; paper for a white fill, on GeomBoxplot/GeomLabel/GeomCrossbar/GeomLabelRepel) and GeomSmooth (accent for its default blue line and ribbon fill) — plus the legend key swatch colour, which reads ink directly rather than going through this trait method. A handful of geoms are left uncovered on purpose: GeomDotplot’s color field is dead config (never drawn); GeomQQLine/GeomCandlestick/GeomOhlc’s defaults are deliberate semantic colours, not neutral ones; GeomQQBand’s mid-grey fill doesn’t match this type’s black/white checks; and GeomCalendarBorder already reads its colour from the dedicated Theme::calendar_month_border element. See sipemu/ggplot-rs#142.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§ink: Option<(u8, u8, u8)>

Replaces a geom’s built-in black / (50, 50, 50) line, text or outline colour (including the legend key colour).

§paper: Option<(u8, u8, u8)>

Replaces a geom’s built-in white fill.

§accent: Option<(u8, u8, u8)>

Replaces the smooth line’s built-in colour.

§family: Option<String>

Font family — the middle tier of B2-6’s resolution order (a geom’s own fontfamily, then this, then theme.text.family).

Implementations§

Source§

impl ElementGeom

Source

pub fn with_ink(self, color: (u8, u8, u8)) -> Self

Builder for ink — #[non_exhaustive] blocks a cross-crate struct literal even with ..Default::default(), so each field gets one of these.

Source

pub fn with_paper(self, color: (u8, u8, u8)) -> Self

Builder for paper.

Source

pub fn with_accent(self, color: (u8, u8, u8)) -> Self

Builder for accent.

Source

pub fn with_family(self, family: &str) -> Self

Builder for family.

Trait Implementations§

Source§

impl Clone for ElementGeom

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ElementGeom

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ElementGeom

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V