Table of Contents
Fetching ...

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.

colorspace: A Python Toolbox for Manipulating and Assessing Colors and Palettes

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.
Paper Structure (7 sections, 5 figures)

This paper contains 7 sections, 5 figures.

Figures (5)

  • Figure 1: Swatches of four HCL-based sequential palettes: pal1 is the predefined HCL-based viridis palette, pal2 is identical to pal2 but created "by hand" and pal3 and pal4 are modified versions with a triangular chroma paths and reduced hue range, respectively.
  • Figure 2: Overview of the predefined (fully customizable) HCL color palettes.
  • Figure 3: Hue-chroma-luminance spectrum plot (left) and corresponding path in the chroma-luminance coordinate system (where hue changes with luminance) for the custom sequential palette pal4.
  • Figure 4: Example of color vision deficiency emulation and color manipulation using a heatmap. Top/bottom: RGB rainbow based palette and HCL based sequential palette. Left to right: Original colors, deuteranope color vision, and desaturated representation.
  • Figure 5: Example of a matplotlib heatmap and a seaborn density using custom HCL-based colors.