Skip to main content

Geom

Trait Geom 

Source
pub trait Geom: Send + Sync {
    // Required methods
    fn draw(
        &self,
        data: &DataFrame,
        coord: &dyn Coord,
        scales: &ScaleSet,
        theme: &Theme,
        backend: &mut dyn DrawBackend,
    ) -> Result<(), RenderError>;
    fn required_aes(&self) -> Vec<Aesthetic>;
    fn default_stat(&self) -> Box<dyn Stat>;
    fn default_position(&self) -> Box<dyn Position>;
    fn default_params(&self) -> GeomParams;
    fn name(&self) -> &str;

    // Provided methods
    fn set_series_color(&mut self, _color: (u8, u8, u8)) { ... }
    fn include_zero_baseline(&self) -> bool { ... }
    fn allows_infinite(&self) -> bool { ... }
    fn setup_data(&self, _data: &mut DataFrame) { ... }
    fn inherit_aes(&self) -> bool { ... }
}
Expand description

Trait for geometric objects that draw data on the plot.

Required Methods§

Source

fn draw( &self, data: &DataFrame, coord: &dyn Coord, scales: &ScaleSet, theme: &Theme, backend: &mut dyn DrawBackend, ) -> Result<(), RenderError>

Draw this geometry.

Source

fn required_aes(&self) -> Vec<Aesthetic>

Required aesthetics.

Source

fn default_stat(&self) -> Box<dyn Stat>

Default stat for this geom.

Source

fn default_position(&self) -> Box<dyn Position>

Default position adjustment.

Source

fn default_params(&self) -> GeomParams

Non-mapped visual defaults.

Source

fn name(&self) -> &str

Name for debug/display.

Provided Methods§

Source

fn set_series_color(&mut self, _color: (u8, u8, u8))

Apply a brand/primary color to this geom’s single-series default (its color or fill). The build pipeline calls this only when the layer has no color/fill aesthetic mapped, so an explicit mapping always wins. The default is a no-op; series geoms override it.

Source

fn include_zero_baseline(&self) -> bool

Whether this geom draws from a 0 baseline, so the Y scale should include 0 even when y is explicitly mapped (bars/columns/area/histograms — as in ggplot2). Default false.

Source

fn allows_infinite(&self) -> bool

Whether -Inf/Inf position values are meaningful for this geom (ggplot2: “extend to the panel edge”). Rows with infinite positions are otherwise dropped with a warning before stats run. NaN is always dropped. Default false; geom_rect returns true.

Source

fn setup_data(&self, _data: &mut DataFrame)

Geom-specific data preparation after the stat and position steps but before scale training (ggplot2’s GeomX$setup_data) — e.g. a tile adds its xmin/xmax/ymin/ymax extents so continuous scales train on them. Default: no-op.

Source

fn inherit_aes(&self) -> bool

Whether the layer inherits the plot-level aesthetic mapping (ggplot2’s inherit.aes). Reference-line geoms return false, as in ggplot2, so a plot-level color/x/y mapping does not leak into a geom_hline. Default true.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Geom for GeomAbline

Source§

impl Geom for GeomArea

Source§

impl Geom for GeomBar

Source§

impl Geom for GeomBin2d

Source§

impl Geom for GeomBlank

Source§

impl Geom for GeomBoxplot

Source§

impl Geom for GeomBracket

Source§

impl Geom for GeomCandlestick

Source§

impl Geom for GeomCensorMarks

Source§

impl Geom for GeomCol

Source§

impl Geom for GeomContour

Source§

impl Geom for GeomCooksContour

Source§

impl Geom for GeomCount

Source§

impl Geom for GeomCrossbar

Source§

impl Geom for GeomCurve

Source§

impl Geom for GeomDensity

Source§

impl Geom for GeomDensity2d

Source§

impl Geom for GeomDotplot

Source§

impl Geom for GeomErrorbar

Source§

impl Geom for GeomErrorbarh

Source§

impl Geom for GeomFreqpoly

Source§

impl Geom for GeomHex

Source§

impl Geom for GeomHistogram

Source§

impl Geom for GeomHline

Source§

impl Geom for GeomJitter

Source§

impl Geom for GeomLabel

Source§

impl Geom for GeomLabelRepel

Source§

impl Geom for GeomLine

Source§

impl Geom for GeomLinerange

Source§

impl Geom for GeomOhlc

Source§

impl Geom for GeomPath

Source§

impl Geom for GeomPoint

Source§

impl Geom for GeomPointrange

Source§

impl Geom for GeomPolygon

Source§

impl Geom for GeomQQ

Source§

impl Geom for GeomQQBand

Source§

impl Geom for GeomQQLine

Source§

impl Geom for GeomRaster

Source§

impl Geom for GeomRect

Source§

impl Geom for GeomRibbon

Source§

impl Geom for GeomRug

Source§

impl Geom for GeomSegment

Source§

impl Geom for GeomSmooth

Source§

impl Geom for GeomSpoke

Source§

impl Geom for GeomStep

Source§

impl Geom for GeomStepribbon

Source§

impl Geom for GeomText

Source§

impl Geom for GeomTextRepel

Source§

impl Geom for GeomTile

Source§

impl Geom for GeomViolin

Source§

impl Geom for GeomVline