Skip to content

Colors

tinytopics.colors

pal_tinytopics(format='hex')

pal_tinytopics(format: Literal['hex']) -> MutableSequence[str]
pal_tinytopics(format: Literal['rgb', 'lab']) -> NDArray[np.float64]

The tinytopics 10 color palette.

A rearranged version of the original Observable 10 palette. Reordered to align with the color ordering of the D3 Category 10 palette, also known as matplotlib.cm.tab10. The rearrangement aims to improve perceptual familiarity and color harmony, especially when used in a context where color interpolation is needed.

Parameters:

Name Type Description Default
format ColorFormat

Returned color format. Options are: hex: Hex strings (default). rgb: Array of RGB values. lab: Array of CIELAB values.

'hex'

Returns:

Type Description
MutableSequence[str] | NDArray[float64]
  • If format='hex', returns a list of hex color strings.
MutableSequence[str] | NDArray[float64]
  • If format='rgb', returns an Nx3 numpy array of RGB values.
MutableSequence[str] | NDArray[float64]
  • If format='lab', returns an Nx3 numpy array of CIELAB values.

Raises:

Type Description
ValueError

If format is not 'hex', 'rgb', or 'lab'.

scale_color_tinytopics(n)

A tinytopics 10 color scale. If > 10 colors are required, will generate an interpolated color palette based on the 10-color palette in the CIELAB color space using B-splines.

Parameters:

Name Type Description Default
n int

The number of colors needed.

required

Returns:

Type Description
ListedColormap

A colormap with n colors, possibly interpolated from the 10 colors.