Documentation
¶
Overview ¶
Package coord defines coordinate systems that control how data positions are mapped to the 2D plotting surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // TransLog10 applies base-10 logarithm. Suitable for data spanning // multiple orders of magnitude. Values ≤ 0 are clamped by the // pipeline to a finite floor. TransLog10 = TransFunc{Name: "log10"} // TransLog2 applies base-2 logarithm. Useful for genomic fold-change, // doubling-time, and binary-scale data. TransLog2 = TransFunc{Name: "log2"} // TransSqrt applies square root. Useful for count data and variances. // Negative values are clamped to zero by the pipeline. TransSqrt = TransFunc{Name: "sqrt"} // TransReverse negates values, flipping axis direction. TransReverse = TransFunc{Name: "reverse"} // TransIdentity is a no-op transform. The build pipeline skips // identity transforms entirely. TransIdentity = TransFunc{Name: identityName} )
Built-in axis transforms.
These are specification-only — they carry no math functions. The build pipeline resolves their Names to engine operations with domain clamping and to inverse functions for tick formatting.
Functions ¶
This section is empty.
Types ¶
type Coord ¶
type Coord interface {
// Transform maps normalized (x, y) ∈ [0,1]² to pixel coordinates
// within the data area of dimensions (width, height).
Transform(x, y, width, height float64) (px, py float64)
// String returns a human-readable label.
String() string
}
Coord transforms scaled data positions (in [0,1] normalized space) into plot-surface positions.
func Cartesian ¶
func Cartesian() Coord
Cartesian returns the default Cartesian coordinate system. x maps to horizontal (left→right), y maps to vertical (bottom→top).
func CartesianZoom ¶ added in v0.0.9
CartesianZoom returns a Cartesian coordinate system with viewport zoom. Unlike [Plot.XLim]/[Plot.YLim] which set scale bounds early, CartesianZoom overrides bounds after scale training without filtering data — all data participates in stat computations, only the visible window changes.
Pass nil for either limit endpoint to auto-detect from training.
func Fixed ¶ added in v0.0.9
Fixed returns a Cartesian coordinate system with a fixed aspect ratio. ratio is defined as (pixels per data-unit-y) / (pixels per data-unit-x). ratio = 1 gives equal scaling — one unit of x occupies the same pixel length as one unit of y.
func Polar ¶
func Polar() Coord
Polar returns a polar coordinate system where x maps to angle (theta, 0→2π) and y maps to radius (0→1). Center is at (w/2, h/2).
func Trans ¶ added in v0.0.9
Trans returns a Cartesian coordinate system with per-axis mathematical transforms applied post-stat. Unlike scale transforms (e.g., scale.Log10) which transform data before stat computations, coord.Trans transforms the data columns via the engine after stats complete but before scales are trained. This means statistics run on raw data, but scales, ticks, and rendering all operate on transformed values.
Use built-in transforms (TransLog10, TransSqrt, etc.).
type Fixer ¶ added in v0.0.9
type Fixer interface {
// AspectRatio returns the desired y/x aspect ratio.
// ratio = 1 means one unit of x occupies the same pixel length as one
// unit of y. ratio = 2 means y is stretched to twice the x scale.
AspectRatio() float64
}
Fixer is an optional interface implemented by coordinate systems that enforce a fixed aspect ratio. The render pipeline checks for this when computing panel dimensions.
type TransFunc ¶ added in v0.0.9
type TransFunc struct {
Name string
}
TransFunc names a bijective mathematical axis transformation.
The coord package is a pure specification layer — it carries no math. The build pipeline resolves Name to the appropriate engine [MathKernel] operation for column-level transforms, and to the matching inverse function for tick-label formatting.
Built-in names: "log10", "log2", "sqrt", "reverse", "identity".
func (TransFunc) IsIdentity ¶ added in v0.0.9
IsIdentity reports whether this transform is a no-op.
type Transformer ¶ added in v0.0.9
type Transformer interface {
// XTrans returns the X-axis TransFunc specification.
XTrans() TransFunc
// YTrans returns the Y-axis TransFunc specification.
YTrans() TransFunc
}
Transformer is an optional interface implemented by coordinate systems that apply per-axis mathematical transforms post-stat. The build pipeline checks for this after stat transforms and dispatches to the engine's MathKernel for column-level computation, before scale training.
type Zoomer ¶ added in v0.0.9
type Zoomer interface {
// ZoomBounds returns the zoom viewport limits.
// nil entries mean "use the trained scale bounds".
ZoomBounds() (xlim, ylim [2]*float64)
}
Zoomer is an optional interface implemented by coordinate systems that provide viewport zoom limits. The build pipeline checks for this after scale training and overrides scale bounds accordingly.