Skip to main content

ggplot_rs/stat/
mod.rs

1pub mod bin;
2pub mod bin2d;
3pub mod bindot;
4pub mod binhex;
5pub mod boxplot;
6#[cfg(feature = "ggpubr")]
7pub mod compare_means;
8pub mod contour;
9pub mod contour_filled;
10#[cfg(feature = "ggpubr")]
11pub mod cor;
12pub mod count;
13pub mod density;
14pub mod density2d;
15pub mod dist;
16pub mod ecdf;
17pub mod ellipse;
18pub mod function;
19pub mod identity;
20pub mod loess;
21pub mod marching_squares;
22pub mod qq;
23#[cfg(feature = "regression")]
24pub mod quantile;
25pub mod smooth;
26pub mod sum;
27pub mod summary;
28pub mod summary2d;
29pub mod summary_bin;
30pub mod ydensity;
31
32use crate::aes::{Aes, Aesthetic};
33use crate::data::DataFrame;
34use crate::scale::ScaleSet;
35
36/// Trait for statistical transformations.
37pub trait Stat: Send + Sync {
38    /// Transform data for a single group.
39    fn compute_group(&self, data: &DataFrame, scales: &ScaleSet) -> DataFrame;
40
41    /// Required aesthetics this stat needs.
42    fn required_aes(&self) -> Vec<Aesthetic>;
43
44    /// Default aesthetic mappings this stat produces.
45    fn default_aes(&self) -> Aes {
46        Aes::default()
47    }
48
49    /// If true, the stat receives every row of a panel at once (grouped only by
50    /// facet variables) instead of once per aesthetic group. Needed for
51    /// cross-group comparisons such as `stat_compare_means`, which must see all
52    /// groups together. Defaults to per-group behaviour.
53    fn panelwise(&self) -> bool {
54        false
55    }
56
57    /// Name for debug/display.
58    fn name(&self) -> &str;
59}