Documentation
¶
Overview ¶
Package position defines position adjustments that control how overlapping geometries are arranged. In ggplot2's grammar, position adjustments are applied after statistical transforms and before final rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pos ¶
type Pos interface {
// Adjust modifies (x, y) positions for a single group within a layer.
// groupIdx is the 0-based index of this group, nGroups is the total count.
// width is the available bin width for dodging/stacking calculations.
Adjust(xs, ys []float64, width float64, groupIdx, nGroups int) ([]float64, []float64)
// String returns a human-readable label.
String() string
}
Pos adjusts the positions of geometric elements to handle overlap. Each adjustment receives the raw data coordinates and group metadata, and returns adjusted coordinates.
func Dodge ¶
func Dodge() Pos
Dodge returns a position that shifts groups side by side within each bin. This is the standard adjustment for grouped bar charts.
func Jitter ¶
Jitter returns a position that adds random noise to (x, y) to reduce overplotting. The jitter is reproducible: same data length produces same offsets.
func Stack ¶
func Stack() Pos
Stack returns a position that stacks groups vertically. Each group's y-values are offset by the cumulative sum of prior groups.
NOTE: Real stacking requires the pipeline coordinator to accumulate offsets across groups. This is not yet implemented — calling Stack() with groupIdx > 0 will panic. Use Dodge or Identity instead.