Visualize.Scale.Color (Visualize v0.2.35)

Copy Markdown View Source

Color scales for encoding data with colors.

Provides sequential and diverging color scales with various built-in color schemes.

Summary

Functions

Applies the scale to get a color

Returns 0: a colour scale has no bandwidth

Enables or disables clamping

Creates a diverging color scale

Sets the domain

Returns nil: a colour scale is not invertible

Identity

Identity: a colour scale has no padding

Sets the range (color interpolator)

Gets a color scheme by name

Returns the list of available color schemes

Creates a sequential color scale

Linear.ticks/2 over the domain's extent: [d0, d1] sequential, [d0, d2] diverging

Types

t()

@type t() :: %Visualize.Scale.Color{
  clamp?: boolean(),
  domain: [number()],
  interpolator: (number() -> String.t()) | [String.t()],
  type: :sequential | :diverging
}

Functions

apply(color, value)

@spec apply(t(), number()) :: String.t()

Applies the scale to get a color

bandwidth(color)

@spec bandwidth(t()) :: 0

Returns 0: a colour scale has no bandwidth

clamp(scale, clamp?)

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

Enables or disables clamping

diverging(interpolator)

@spec diverging(atom() | [String.t()] | (number() -> String.t())) :: t()

Creates a diverging color scale

domain(scale, list)

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

Sets the domain

invert(color, value)

@spec invert(t(), any()) :: nil

Returns nil: a colour scale is not invertible

nice(scale)

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

Identity

padding(scale, padding)

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

Identity: a colour scale has no padding

range(scale, interpolator)

@spec range(t(), atom() | [String.t()]) :: t()

Sets the range (color interpolator)

scheme(name)

@spec scheme(atom()) :: [String.t()] | nil

Gets a color scheme by name

schemes()

@spec schemes() :: [atom()]

Returns the list of available color schemes

sequential(interpolator)

@spec sequential(atom() | [String.t()] | (number() -> String.t())) :: t()

Creates a sequential color scale

ticks(color, count)

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

Linear.ticks/2 over the domain's extent: [d0, d1] sequential, [d0, d2] diverging