Percentile-band generator: a median line with an inner and an outer band around it (spec/04 §14, D-28).
A composition of Visualize.Shape.Area and Visualize.Shape.Line with a fixed output
shape: generate/2 returns %{outer: d, inner: d, median: d}, each path exactly what the
standalone generator would produce, or nil for a band that is not set.
Examples
band =
Visualize.Shape.PercentileBand.new()
|> Visualize.Shape.PercentileBand.x(fn d -> Visualize.Scale.apply(x_scale, d.t) end)
|> Visualize.Shape.PercentileBand.median(fn d -> Visualize.Scale.apply(y_scale, d.p50) end)
|> Visualize.Shape.PercentileBand.inner({&y.(&1.p25), &y.(&1.p75)})
|> Visualize.Shape.PercentileBand.outer({&y.(&1.p5), &y.(&1.p95)})
|> Visualize.Shape.PercentileBand.curve(:monotone_x)
%{outer: outer, inner: inner, median: median} =
Visualize.Shape.PercentileBand.generate(band, samples)
Summary
Types
The output: one entry per path, nil where the band or median is unset.
The lower and upper percentile of a band.
Functions
Sets the curve type and options, applied to every path
Sets the defined predicate, applied to every path (spec/04 §1.2)
Returns %{outer:, inner:, median:} of SVG path-data strings, nil where unset
Returns %{outer:, inner:, median:} of IR.Path, nil where unset
Sets the inner band as a {lo, hi} pair of accessors; nil clears it
Sets the median accessor; nil clears it
Creates a generator reading tuple element 0 as x, with no median and no bands
Sets the outer band as a {lo, hi} pair of accessors; nil clears it
Sets the x accessor: 1-arity function, atom field, or numeric constant
Types
@type accessor() :: Visualize.Shape.Line.accessor()
@type output(path) :: %{outer: path | nil, inner: path | nil, median: path | nil}
The output: one entry per path, nil where the band or median is unset.
The lower and upper percentile of a band.
@type t() :: %Visualize.Shape.PercentileBand{ curve: Visualize.Shape.Curve.curve_type(), curve_opts: keyword(), defined: (any() -> boolean()) | nil, inner: {(any() -> number()), (any() -> number())} | nil, median: (any() -> number()) | nil, outer: {(any() -> number()), (any() -> number())} | nil, x: accessor() | nil }
Functions
@spec curve(t(), Visualize.Shape.Curve.curve_type(), keyword()) :: t()
Sets the curve type and options, applied to every path
Sets the defined predicate, applied to every path (spec/04 §1.2)
@spec generate(t(), Visualize.Data.Table.source()) :: output(String.t())
Returns %{outer:, inner:, median:} of SVG path-data strings, nil where unset
@spec generate_path(t(), Visualize.Data.Table.source()) :: output(Visualize.IR.Path.t())
Returns %{outer:, inner:, median:} of IR.Path, nil where unset
Sets the inner band as a {lo, hi} pair of accessors; nil clears it
Sets the median accessor; nil clears it
@spec new() :: t()
Creates a generator reading tuple element 0 as x, with no median and no bands
Sets the outer band as a {lo, hi} pair of accessors; nil clears it
Sets the x accessor: 1-arity function, atom field, or numeric constant