distinctipy

raw JSON →
1.3.4 verified Mon Apr 27 auth: no python

A lightweight Python library for generating visually distinct colours. Current version: 1.3.4. Release cadence: infrequent, minor patches.

pip install distinctipy
error ModuleNotFoundError: No module named 'distinctipy'
cause Library not installed or installed in wrong environment.
fix
pip install distinctipy
error AttributeError: module 'distinctipy' has no attribute 'color_swatch'
cause color_swatch was added in v1.2.0; older version or incorrect import.
fix
Upgrade: pip install --upgrade distinctipy. Then use: from distinctipy import color_swatch
breaking Python 3.7 support dropped in v1.3.4.
fix Use Python >=3.8, or stay on v1.3.3.
deprecated The `n` parameter name for number of colors is retained but may change in future. Use keyword argument.
fix Call as get_colors(n=15) instead of get_colors(15).
gotcha Colors are returned as RGB tuples with values 0-1, not 0-255. Direct use with matplotlib expects 0-1.
fix Multiply by 255 if you need 0-255 integers: [tuple(int(c*255) for c in color) for color in colors].

Generate 15 distinct colors and display their swatches.

from distinctipy import get_colors, color_swatch
n = 15
colors = get_colors(n)
print(colors[:3])
color_swatch(colors)