Documentation
¶
Overview ¶
Package stat provides statistical transformations for the Grammar of Graphics. Stats compute derived data (bins, counts, densities, smooths) from raw data, producing new datasets that are then rendered by geometries.
Each stat implements the Stat interface and is registered with a typed Name for lookup during pipeline compilation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Bins int // number of bins (histogram/bin stat); 0 = auto
BinMethod string // binning strategy: "sturges" (default), "scott", "fd", "sqrt"
Method string // smoothing method: "lm", "loess"
Points int // number of output grid points
Bandwidth float64 // KDE bandwidth; 0 = Silverman auto-select
Whisker string // boxplot whisker rule: "tukey" (default 1.5×IQR), "range" (min-max)
Notch bool // boxplot: compute notch confidence interval around median
}
Options holds typed parameters for stat computations, replacing magic string keys like "__bins".
type Stat ¶
type Stat interface {
// Name returns the stat's typed identifier.
Name() Name
// RequiredAes returns the aesthetic channels this stat needs.
RequiredAes() []string
// OutputSchema returns the column names this stat produces.
OutputSchema() []string
// OutputMapping returns the aesthetic-to-column mapping for the stat's
// output. The renderer uses this to know which output column maps to
// which aesthetic channel (e.g., {"x": "x", "y": "count"} for stat_bin).
// Returns nil for identity stats (no rewriting needed).
// This replaces hardcoded per-stat switches in the rendering pipeline.
OutputMapping() map[string]string
// Compute performs the transformation.
Compute(ctx context.Context, ds dataset.Dataset, mapping map[string]string, opts Options) (dataset.Dataset, error)
}
Stat computes a statistical transformation on a dataset, producing a new (possibly differently shaped) dataset. The transformed dataset's columns depend on the stat type.
Click to show internal directories.
Click to hide internal directories.