Now available for the python enthusiasts!

Python colorspace package

The R colorspace package exists since quite a while but was only available in R so far. This package (which is in an early beta state at the moment) provides the same features and methods as the R colorspace package in native python code. Give it a shot!

Some good news for python enthusiasts. I have had some “free time” and decided to port the R colorspace package to python. The result is the python colorspace package for Python 2.7 and Python 3.6+.

Today I decided to publish a first early beta release (v0.1.0). There might be some hilarious bugs (or features) in the current version and not all features are yet implemented, but should be a working tech demo! If you are interested you can give it a shot. Feel free to report bugs and/or contribute to this little project if you want to.

The documentation is available on but needs some more attention from my side. Not all functions are documented, nothing is proof-read, and some pages are still empty (e.g., the usage examples). I’ll try to work on it as soon as possible.

What the package does

The colorspace provides some handy functions to create and use effective color maps for scientific data visualization based on the Hue-Chroma-Luminance color space. In contrast to the widely used Red-Green-Blue color space the HCL color space is based on how humans perceive colors. The three dimensions of the HCL color space allow to directly control the three dimensions of color perception and to avoid “bad” or inefficient color maps which can, in some cases, obscure the data presented in the figures and make them hard to interpret or even mislead the readers.

Choose Color Palettes

The choose_palette() function provides an interactive TclTk interface to customize color palettes. Some simple demo plots allow to directly access the look and feel of the palettes. Furthermore, the interface allows to check the selected color palettes for possible issues with respect to color vision deficiencies (color blindness).

Screenshot of the ``choose_palette()`` GUI.

The GUI returns a hclpalette object with a range of standardized methods to draw a set of colors:

Draw 3 unique colors from the sequential color palette specified via GUI.

As the returned object is an object it also allows you to dynamically draw a different number of colors from the palette, e.g,. 100:

Draw 100 unique colors from the sequential color palette specified via GUI.

Or simply return a vector with three HEX colors. There is even a method to directly get a matplotlib cmap (matplotlib.colors.LinearSegmentedColormap).

Draw a HEX color list from the palette specified via GUI.

There are some more nice features such as swatchplot and specplot to access the palette, functions to simulate color vision deficiencies (deutan, protan, tritan, and desaturate), and more. The package also includes a colorlib module which allows to easily transform colors between a set of different color spaces including hex colors, CIE-XYZ, HCL, and others.

Again, it’s a beta! You can blame me, but it would be nice to get some feedback instead :). Bug-reports and issues welcome which help to fix existing errors and to improve the package.


news python python-colorspace