Macaw.Draw.Scale.Symlog (macaw_draw v0.1.0)

Copy Markdown View Source

A continuous symmetric-log scale, for data spanning orders of magnitude through zero (spec/06 §7).

The transform is S(x) = sign(x) · ln(1 + |x| / c), inverse S⁻¹(y) = sign(y) · c · (e^|y| − 1), c the constant, above 0: linear near zero and logarithmic beyond c. Its ticks are the signed decades of the constant and zero, its nice/1 is Macaw.Draw.Scale.Linear's, and when it clamps it clamps its output to the range's bounds.

Summary

Types

A refusal: faults with their paths.

t()

Functions

The range value of value through the transform, 0.5 of the range when the transformed domain collapses, clamped to the range's bounds when the scale clamps; nil for a value that is not a number.

0: a symlog scale has no bandwidth.

Sets clamping of the output to the range; answers the struct.

Sets the transition constant, a number above 0: {:ok, scale}, or {:error, [{[], {:not_positive, c}}]}.

constant/2, answering the scale or raising Macaw.Draw.Error.

Sets the domain, a two-element list or tuple of numbers, stored as a list.

domain/2, answering the scale or raising Macaw.Draw.Error.

The domain value of a range value, S⁻¹(S(d0) + t · (S(d1) − S(d0))); never clamps.

The default scale: domain [-1, 1], range [0, 1], constant 1.

Identity: a symlog scale has no padding.

Sets the range, a two-element list or tuple of numbers, stored as a list.

range/2, answering the scale or raising Macaw.Draw.Error.

The signed decades of the constant and zero inside the domain, ascending: −c · 10^k below zero, 0 when the domain holds it, c · 10^k above, each side strided to about count values (spec/06 §7.2). A domain holding no decade answers [].

Types

error()

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

A refusal: faults with their paths.

t()

@type t() :: %Macaw.Draw.Scale.Symlog{
  clamp?: boolean(),
  constant: number(),
  domain: [number()],
  range: [number()]
}

Functions

apply(s, v)

@spec apply(t(), term()) :: float() | nil | error()

The range value of value through the transform, 0.5 of the range when the transformed domain collapses, clamped to the range's bounds when the scale clamps; nil for a value that is not a number.

bandwidth(arg1)

@spec bandwidth(t()) :: 0 | error()

0: a symlog scale has no bandwidth.

clamp(scale, clamp?)

@spec clamp(t(), boolean()) :: t() | error()

Sets clamping of the output to the range; answers the struct.

constant(scale, c)

@spec constant(t(), term()) :: {:ok, t()} | error()

Sets the transition constant, a number above 0: {:ok, scale}, or {:error, [{[], {:not_positive, c}}]}.

constant!(scale, c)

@spec constant!(t(), term()) :: t()

constant/2, answering the scale or raising Macaw.Draw.Error.

domain(scale, domain)

@spec domain(t(), term()) :: {:ok, t()} | error()

Sets the domain, a two-element list or tuple of numbers, stored as a list.

domain!(scale, domain)

@spec domain!(t(), term()) :: t()

domain/2, answering the scale or raising Macaw.Draw.Error.

invert(s, value)

@spec invert(t(), term()) :: float() | nil | error()

The domain value of a range value, S⁻¹(S(d0) + t · (S(d1) − S(d0))); never clamps.

new()

@spec new() :: t()

The default scale: domain [-1, 1], range [0, 1], constant 1.

nice(scale)

@spec nice(t()) :: t() | error()

Macaw.Draw.Scale.Linear.nice/1's domain.

padding(scale, padding)

@spec padding(t(), number()) :: t() | error()

Identity: a symlog scale has no padding.

range(scale, range)

@spec range(t(), term()) :: {:ok, t()} | error()

Sets the range, a two-element list or tuple of numbers, stored as a list.

range!(scale, range)

@spec range!(t(), term()) :: t()

range/2, answering the scale or raising Macaw.Draw.Error.

ticks(s, count)

@spec ticks(t(), number()) :: [number()] | error()

The signed decades of the constant and zero inside the domain, ascending: −c · 10^k below zero, 0 when the domain holds it, c · 10^k above, each side strided to about count values (spec/06 §7.2). A domain holding no decade answers [].