Colourmap

1.2.1 · active · verified Thu Apr 16

The `colourmap` Python package, currently at version 1.2.1, generates N unique colors from a specified input colormap or list of colors. It also provides utilities for converting between RGB and HEX color formats and can create linear gradients. The package appears to have a moderate release cadence, with recent updates in late 2025.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate unique colors using the `colourmap` function from a default colormap or a provided list of colors. It also shows the utility functions for converting between RGB and HEX color formats. The core functionality is `generate_unique_colors` which can take an `n_colors` parameter or an `input_colors` list.

from colourmap import colourmap

# Generate 5 unique colors from a default colormap
colors_hex = colourmap.generate_unique_colors(n_colors=5)
print(f"Generated HEX colors: {colors_hex}")

# Generate 3 unique colors from a specified list of input colors (e.g., using a seaborn palette)
# For demonstration, we'll use a simple list; in a real scenario, this might come from seaborn.color_palette
input_palette = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b']
colors_from_palette_hex = colourmap.generate_unique_colors(input_colors=input_palette, n_colors=3)
print(f"Generated HEX colors from palette: {colors_from_palette_hex}")

# Convert RGB to HEX
rgb_color = (255, 0, 0)
hex_color = colourmap.rgb_to_hex(rgb_color)
print(f"RGB {rgb_color} to HEX: {hex_color}")

# Convert HEX to RGB
hex_color_input = '#00FF00'
rgb_color_output = colourmap.hex_to_rgb(hex_color_input)
print(f"HEX {hex_color_input} to RGB: {rgb_color_output}")

view raw JSON →