gsplot.colors#

colors(n=10, cmap='viridis', *, reverse=False)#

Return evenly spaced publication colors from a Matplotlib colormap.

Parameters:
  • n (int) – Positive number of RGBA rows, defaulting to 10.

  • cmap (str | Colormap) – Registered Matplotlib colormap name or native Colormap object.

  • reverse (bool) – Reverse the sampled row order when True.

Returns:

New finite floating-point (n, 4) RGBA array.

Return type:

numpy.ndarray

Raises:

PlotError – If the count, colormap, or reverse control is invalid.

Notes

Multiple colors cover the inclusive interval from zero to one. One color samples the midpoint 0.5. The operation does not register or mutate a colormap.

Examples

>>> import gsplot as gs
>>> palette = gs.colors(3)
>>> palette.shape
(3, 4)