Skip to main content

Perceptually-distinct color palette generator for data visualization in Python.

Project description

Color-Craftsman

License: MIT Python Contributions Welcome Development Status PyPI Downloads

Description

Color-Craftsman creates perceptually-distinct color palettes for data visualization in Python. While many great plotting libaries exist, they often rely on fixed color palettes and generally have few colors. These colors often conflict with one another. Color-Craftsman allows users to create a palette of colors that are perceptually distinct from one another. This allows for more colors to be used in a plot without sacrificing readability.

Installation

pip install color-craftsman

Usage

Simple examples are shown below. For more examples, see the examples directory.

Creating a Random Palette

import color_craftsman as cc

# Create a palette with 5 colors
palette = cc.generate_palette(
    5,
    min_dist=30,
    seed=11,
    output_format="rgb",
)
cc.visualize_palette(palette, show=True)

base_palette

Note: a random seed can be provided to ensure reproducibility. Distance is the distance between colors in the palette. A larger distance will result in more distinct colors. If the distance is too large, a warning message will be displayed. Too large of distances can result in colors that are too similar to each other due to clipping in the RGB color space. Distance is defined as the Delta-E color difference between colors in the palette.

Creating a Palette from a Base Palette

import color_craftsman as cc

# Create a palette with 10 total colors
extended_palette = cc.extend_palette(
    [
        np.array([153, 191, 80]),
        np.array([107, 88, 11]),
        np.array([42, 19, 119]),
        np.array([93, 110, 244]),
        np.array([213, 114, 236]),
    ],
    10,
    min_dist=10,
    seed=18,
    palette_format="rgb",
    output_format="rgb",
)
cc.visualize_palette(extended_palette, show=True)

extended_palette

Visualizing a Palette

import color_craftsman as cc

cc.visualize_palette(palette, show=True)

Colorblind-Safe Palettes

To guard against deutranopia, protanopia, and tritanopia, use the colorblind_safe parameter.

palette = cc.generate_palette(
    5,
    min_dist=30,
    seed=22,
    output_format="rgb",
    colorblind_safe=True,
)
cc.visualize_palette(extended_palette, show=True)

colorblind_palette

Specific Colorblindness-Safe Palettes

If you want to guard against specific-forms of colorblindness, you can specify the type of colorblindness using the following arguments: deuteranomaly_safe, protanomaly_safe, and tritanomaly_safe.

Deuteranopia-Safe Palette
palette = cc.generate_palette(
    5,
    min_dist=30,
    seed=33,
    output_format="rgb",
    deuteranomaly_safe=True,
)
cc.visualize_palette(palette, show=True)

deuteranomaly_palette

Protanopia-Safe Palette
palette = cc.generate_palette(
    5,
    min_dist=30,
    seed=44,
    output_format="rgb",
    protanomaly_safe=True,
)
cc.visualize_palette(palette, show=True)

protanopia_palette

Tritanopia-Safe Palette
palette = cc.generate_palette(
    5,
    min_dist=30,
    seed=55,
    output_format="rgb",
    tritanomaly_safe=True,
)
cc.visualize_palette(palette, show=True)

tritanopia_palette

Contributing

Contributions are welcome! If you'd like to contribute to the project, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Test your changes thoroughly.
  5. Submit a pull request.
  6. Add caharper as a reviewer.

Please ensure your code adheres to the project's coding style and conventions.

License

This project is licensed under the MIT License.

Contact

If you have any questions, suggestions, or feedback, feel free to reach out:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

color_craftsman-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

color_craftsman-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file color_craftsman-0.1.0.tar.gz.

File metadata

  • Download URL: color_craftsman-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/22.5.0

File hashes

Hashes for color_craftsman-0.1.0.tar.gz
Algorithm Hash digest
SHA256 95074e423e692750f3c3768ebbd4e99f679bef2cf1512ee09e6d25903bbf17c1
MD5 5779100d251b812dff5561dd5fbf6c34
BLAKE2b-256 38eccab0bbb0171e852fd3e07a62dee3dd98b9c5f20b8d1f88e7bb467e8e6814

See more details on using hashes here.

File details

Details for the file color_craftsman-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: color_craftsman-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/22.5.0

File hashes

Hashes for color_craftsman-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74e361b0395392c203f147c43eea7071e9f4e2a6926458aa3cbe6214047fcc2b
MD5 6cdf1bf133d308c62712e1484464639f
BLAKE2b-256 36cf6eb1503f934ad22fb8a1d653e294c53237c1098568062b9e5eeb2193ac8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page