Visualize.Scale.Log (Visualize v0.2.25)

Copy Markdown View Source

A logarithmic scale for data with exponential distributions.

Useful when data spans many orders of magnitude.

Summary

Functions

Applies the scale to a value

Returns 0: a log scale has no bandwidth

Enables or disables clamping

Sets the domain (must be positive for log scale)

Inverts the scale

Creates a new log scale with optional base

Extends domain to nice powers of the base

Identity: a log scale has no padding

Sets the range

Generates about count tick values, as d3-scale's log ticks do.

Types

t()

@type t() :: %Visualize.Scale.Log{
  base: number(),
  clamp?: boolean(),
  domain: [number()],
  range: [number()]
}

Functions

apply(log, value)

@spec apply(t(), number()) :: float()

Applies the scale to a value

bandwidth(log)

@spec bandwidth(t()) :: 0

Returns 0: a log scale has no bandwidth

clamp(scale, clamp?)

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

Enables or disables clamping

domain(scale, list)

@spec domain(t(), [number()]) :: t()

Sets the domain (must be positive for log scale)

invert(log, value)

@spec invert(t(), number()) :: float()

Inverts the scale

new(base \\ 10)

@spec new(number()) :: t()

Creates a new log scale with optional base

nice(scale)

@spec nice(t()) :: t()

Extends domain to nice powers of the base

padding(scale, padding)

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

Identity: a log scale has no padding

range(scale, list)

@spec range(t(), [number()]) :: t()

Sets the range

ticks(log, count)

@spec ticks(t(), integer()) :: [number()]

Generates about count tick values, as d3-scale's log ticks do.

When the domain spans fewer decades than count and the base is an integer, every k · base^i (1 ≤ k < base) inside the domain is a tick — the familiar 1, 2, 3, … 9, 10, 20, 30 … — and, when that still yields fewer than count / 2 ticks, linear ticks over the domain are used instead. Otherwise the exponents are thinned to about count nice values and mapped back through the base.