# `Macaw.Draw.Shape.PercentileBand`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/shape/percentile_band.ex#L1)

A median line with an inner and an outer band about it (spec/07 §14), copied from
visualize's `Visualize.Shape.PercentileBand`: the standard reading of a distribution
over time, `Macaw.Draw.Shape.Area` and `Macaw.Draw.Shape.Line` composed with a fixed
output shape (visualize D-28).

`x/2` and `median/2` are pixel accessors; `inner/2` and `outer/2` each take a `{lo, hi}`
pair of pixel accessors, `nil` clearing the band. The quantiles come in as accessors over
the data: none is computed here. `curve/2,3` and `defined/2` apply to all three paths.

    iex> alias Macaw.Draw.Shape.PercentileBand
    iex> PercentileBand.generate(PercentileBand.new(), [{0, 1}])
    %{outer: nil, inner: nil, median: nil}

`generate_path/2` answers `%{outer:, inner:, median:}`: each band the area of its pair
(`y0 = lo`, `y1 = hi`) and the median the line, under one curve and predicate, or `nil`
when unset. `generate/2` writes each as path data. They are drawn outer, inner, median.

# `accessor`

```elixir
@type accessor() :: (term() -&gt; term()) | atom() | String.t() | number()
```

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `output`

```elixir
@type output(path) :: %{outer: path | nil, inner: path | nil, median: path | nil}
```

One entry per path, `nil` where the band or the median is unset.

# `t`

```elixir
@type t() :: %Macaw.Draw.Shape.PercentileBand{
  curve: Macaw.Draw.Shape.Curve.curve_type(),
  curve_opts: keyword(),
  defined: (term() -&gt; term()) | nil,
  inner: {(term() -&gt; term()), (term() -&gt; term())} | nil,
  median: (term() -&gt; term()) | nil,
  outer: {(term() -&gt; term()), (term() -&gt; term())} | nil,
  x: (term() -&gt; term()) | nil
}
```

# `curve`

```elixir
@spec curve(t(), term()) :: {:ok, t()} | error()
```

`curve(band, type, [])`.

# `curve`

```elixir
@spec curve(t(), term(), keyword()) :: {:ok, t()} | error()
```

Sets the curve of every path: `{:ok, band}` or `{:error, faults}` (§5.1).

# `curve!`

```elixir
@spec curve!(t(), term(), keyword()) :: t()
```

As `curve/3`, the band itself, raising `Macaw.Draw.Error` with its faults.

# `defined`

```elixir
@spec defined(t(), (term() -&gt; term()) | nil) :: t() | error()
```

Sets the `defined` predicate of every path (§1.2); `nil` clears it.

# `generate`

```elixir
@spec generate(t(), [term()]) :: output(String.t()) | error()
```

`%{outer:, inner:, median:}` of SVG path data, `nil` where unset.

# `generate_path`

```elixir
@spec generate_path(t(), [term()]) :: output(Macaw.Draw.IR.Path.t()) | error()
```

`%{outer:, inner:, median:}` of `Macaw.Draw.IR.Path`, `nil` where unset.

# `inner`

```elixir
@spec inner(t(), {accessor(), accessor()} | nil) :: t() | error()
```

Sets the inner band, a `{lo, hi}` pair of accessors; `nil` clears it.

# `median`

```elixir
@spec median(t(), accessor() | nil) :: t() | error()
```

Sets the median accessor; `nil` clears it.

# `new`

```elixir
@spec new() :: t()
```

A percentile band with `x` from tuple element 0, nothing else set.

# `outer`

```elixir
@spec outer(t(), {accessor(), accessor()} | nil) :: t() | error()
```

Sets the outer band, a `{lo, hi}` pair of accessors; `nil` clears it.

# `x`

```elixir
@spec x(t(), accessor()) :: t() | error()
```

Sets the x accessor: a function, a field, or a number.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
