Skip to main content

Module align

Module align 

Source
Expand description

stat_align — the default stat of geom_area (ggplot2 ≥ 3.4).

Stacking adds y values that share an x. Series sampled at different x would then stack on gaps (a series above one that has no row at some x dips there). stat_align interpolates every group onto one shared set of x positions first, so stacked areas stay continuous (#172).

As ggplot2’s StatAlign:

  • one group in the panel: the data passes through unchanged;
  • the shared positions are every x of the panel plus each group’s zero crossings, and a tiny step adjust either side of each (0.1 % of the x range, at most a third of the smallest gap between positions);
  • each group is linearly interpolated at the positions inside its own x range, and padded with y = 0 one adjust beyond both ends;
  • a group with a single distinct x is dropped; within a group, repeated x keep their first and last row, the first moved one adjust left (a vertical step);
  • every other column is carried from the group’s first row.

Structs§

StatAlign
Interpolates every group of a panel onto shared x positions (see the module docs).