matthewplotlib

matthewplotlib.colormaps

A collection of pre-defined colormaps. They generally come in two flavours:

  • Continuous colormaps: Functions of type float[...] -> uint8[..., 3]. They turn a batch of floats in the range [0.0, 1.0] into a batch of RGB triples.
  • Discrete colormaps: Functions of type int[...] -> uint8[..., 3]. They turn a batch of integer indices into a batch of RGB triples by indexing into the color palette.

For example:

type ContinuousColorMap = Callable[[ArrayLike], numpy.ndarray]
type DiscreteColorMap = Callable[[ArrayLike], numpy.ndarray]
type ColorMap = ContinuousColorMap | DiscreteColorMap
def reds(x: ArrayLike) -> numpy.ndarray:

Red colormap. Simply embeds greyscale value into red channel.

def greens(x: ArrayLike) -> numpy.ndarray:

Green colormap. Simply embeds greyscale value into green channel.

def blues(x: ArrayLike) -> numpy.ndarray:

Blue colormap. Simply embeds greyscale value into blue channel.

def yellows(x: ArrayLike) -> numpy.ndarray:

Yellow colormap. Simply embeds greyscale value into red and green channels.

def magentas(x: ArrayLike) -> numpy.ndarray:

Magenta colormap. Simply embeds greyscale value into red and blue channels.

def cyans(x: ArrayLike) -> numpy.ndarray:

Cyan colormap. Simply embeds greyscale value into green and blue channels.

def divreds(x: ArrayLike) -> numpy.ndarray:

Diverging red/cyan colormap. Uses greyscale value to interpolate between cyan (0.0) and white (0.5) and red (1.0).

def divgreens(x: ArrayLike) -> numpy.ndarray:

Diverging green/magenta colormap. Uses greyscale value to interpolate between magenta (0.0) and white (0.5) and green (1.0).

def divblues(x: ArrayLike) -> numpy.ndarray:

Diverging blue/yellow colormap. Uses greyscale value to interpolate between yellow (0.0) and white (0.5) and blue (1.0).

def cyber(x: ArrayLike) -> numpy.ndarray:

Cyberpunk colormap. Uses greyscale value to interpolate between magenta (0.) and cyan (1.).

def rainbow(x: ArrayLike) -> numpy.ndarray:

Rainbow colormap. Effectively embeds greyscale values as hue in HSV color space.

def magma(x: ArrayLike) -> numpy.ndarray:

Magma colormap by Nathaniel J. Smith and Stefan van der Walt (see https://bids.github.io/colormap/).

Discretised to 256 8-bit colours.

def inferno(x: ArrayLike) -> numpy.ndarray:

Inferno colormap by Nathaniel J. Smith and Stefan van der Walt (see https://bids.github.io/colormap/).

Discretised to 256 8-bit colours.

def plasma(x: ArrayLike) -> numpy.ndarray:

Plasma colormap by Nathaniel J. Smith and Stefan van der Walt (see https://bids.github.io/colormap/).

Discretised to 256 8-bit colours.

def viridis(x: ArrayLike) -> numpy.ndarray:

Viridis colormap by Nathaniel J. Smith, Stefan van der Walt, and Eric Firing (see https://bids.github.io/colormap/).

Discretised to 256 8-bit colours.

def sweetie16(x: ArrayLike) -> numpy.ndarray:

Sweetie-16 colour palette by GrafxKid (see https://lospec.com/palette-list/sweetie-16).

Input should be an array of indices in the range [0,15] (or else it will cycle).

def pico8(x: ArrayLike) -> numpy.ndarray:

PICO-8 colour palette (see https://pico-8.fandom.com/wiki/Palette).

Input should be an array of indices in the range [0,15] (or else it will cycle).

def tableau(x: ArrayLike) -> numpy.ndarray:

Matplotlib Tableau colourmap.

Input should be an array of indices in the range [0,9] (or else it will cycle).

def nouveau(x: ArrayLike) -> numpy.ndarray:

Updated Tableau colourmap (more accessible).

Input should be an array of indices in the range [0,9] (or else it will cycle).