colorspace: A Python Toolbox for Manipulating and Assessing Colors and Palettes
Reto Stauffer, Achim Zeileis
TL;DR
This paper addresses the challenge of selecting perceptually meaningful color palettes for visualizations by introducing colorspace, a Python toolbox that constructs and manipulates palettes in perceptual color spaces, particularly Hue-Chroma-Luminance (HCL). It offers qualitative, sequential, and diverging palette generation along HCL paths, with mapping to hex codes and matplotlib-compatible colormaps, plus extensive visualization and assessment tools. The toolkit also includes color-vision deficiency emulation and desaturation features to evaluate accessibility, and demonstrates seamless integration with Python visualization libraries such as matplotlib, seaborn, and plotly. Collectively, colorspace provides a flexible, extensible framework for creating customizable, perceptually faithful palettes with robust accessibility and workflow integration for Python users.
Abstract
The Python colorspace package provides a toolbox for mapping between different color spaces which can then be used to generate a wide range of perceptually-based color palettes for qualitative or quantitative (sequential or diverging) information. These palettes (as well as any other sets of colors) can be visualized, assessed, and manipulated in various ways, e.g., by color swatches, emulating the effects of color vision deficiencies, or depicting the perceptual properties. Finally, the color palettes generated by the package can be easily integrated into standard visualization workflows in Python, e.g., using matplotlib, seaborn, or plotly.
