facet

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package facet splits a dataset into subsets for "small multiple" panel layouts. Faceting is a core component of the Grammar of Graphics, allowing the same plot specification to be repeated across levels of a categorical variable.

Index

Constants

This section is empty.

Variables

View Source
var ErrFacetConfig = errors.New("facet: invalid configuration")

ErrFacetConfig is returned for invalid facet configuration.

Functions

This section is empty.

Types

type Facet

type Facet interface {
	// Split partitions the dataset into panels. Each panel has a label
	// and a filtered subset of the data.
	Split(ctx context.Context, ds dataset.Dataset) ([]Panel, error)

	// GridDims returns the (rows, cols) grid dimensions for layout.
	// For Wrap, this is computed from the number of panels and nCols.
	GridDims(nPanels int) (rows, cols int)

	// String returns a human-readable description.
	String() string
}

Facet defines how a dataset is split into panels for small-multiple layouts.

func Grid

func Grid(rowCol, colCol string) Facet

Grid creates a facet that arranges panels in a row × col matrix, splitting by one variable for rows and another for columns.

func None

func None() Facet

None returns a no-op facet that produces a single panel.

func Wrap

func Wrap(col string, opts ...WrapOpt) Facet

Wrap creates a facet that wraps panels across a grid layout, splitting the data by the given column's distinct values.

type Panel

type Panel struct {
	Label   string
	Dataset dataset.Dataset
}

Panel represents a single facet panel containing a data subset.

type WrapOpt

type WrapOpt func(*wrapFacet)

WrapOpt configures a Wrap facet.

func NCols

func NCols(n int) WrapOpt

NCols sets the number of columns for the wrapped layout.

func NRows

func NRows(n int) WrapOpt

NRows sets the number of rows for the wrapped layout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL