A Toolbox for Manipulating and Assessing Colors and Palettes¶
colorspace is a Python package to create and handle colors and color palettes in Python. Based on the Hue-Chroma-Luminance (HCL) color space effective color palettes can be designed and implemented in your own daily workflow.
This package is based on the R colorspace package to make the tools easily available for Python enthusiasts. More information and an interactive interface can also be found on HCLwizard.org.
The package itself can be found on GitHub and this documentation is also available on GitHub Pages.
Contents¶
- Package Installation
- Color Spaces: Classes and Utilities
- HCL-Based Color Palettes
- Palette Visualization and Assessment
- Apps for Choosing Colors and Palettes Interactively
- Color Vision Deficiency Emulation
- Color Manipulation and Utilities
- Approximating Palettes from Other Packages
- Somewhere over the Rainbow
Other Packages and Further Reading¶
More information and further reading:
HCLwizard.org: More information about the HCL color space, introduction to the colorspace packages (available for R and Python), and some interactive tools to define effective HCL-based color palettes, pick colors, and check existing plots and figures for possible problems in terms of color vision deficiencies.
A list of scientific articles which provide more detailed insights, e.g.,
The end of the rainbow: An open letter to the climate science community by Ed Hawkins, Doug McNeall, David Stephenson, Jonny Williams & Dave Carlson.
Better Figures: Constructive criticism of the graphics of climate science by Doug McNeall.
Scientific articles with more detailed insights:
Zeileis, A., Fisher, J., Hornik, K., Ihaka, R., McWhite, C., Murrell, P., Stauffer, R., & Wilke, C. (2020). colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes. Journal of Statistical Software, 96(1), 1–49, doi: https://doi.org/10.18637/jss.v096.i01
Stauffer, R., Mayr, G. J., Dabernig, M., & Zeileis, A. (2015). Somewhere Over the Rainbow: How to Make Effective Use o f Colors in Meteorological Visualizations. Bulletin of the American Meteorological Society, 96(2), 203–216, doi: 10.1175/BAMS-D-13-00155.1.
Zeileis, A., Hornik, K., & Murrell, P. (2009). Escaping RGBland: Selecting colors for statistical graphics. Computational Statistics & Data Analysis , 53(9), 3259–3270, doi:10.1016/j.csda.2008.11.033.
Ihaka, R., 2003. Colour for presentation graphics. In: Hornik, K., Leisch, F., Zeileis, A. (Eds.), Proceedings of the 3rd International Workshop on Distributed Statistical Computing, Vienna, Austria, ISSN 1609-395X, URL: http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/Ihaka.pdf.
And others. (HCLwizard.org reference list).
Some other packages providing color maps in Python (on top of the default color maps) wich might be of interest:
seaborn: Statistical data visualization. The package also provides access to a range of (mostly) well specified color palettes.
palettable: Color palettes for Python. Formely known as
brewer2mpl
. Provides a range of color palettes including “Brewer2” and “Carto” palettes.ColorBrewer2.org: The source of the brewer colors, interactive web page by Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
Known issues¶
Warning
White point implemented but might require some additional testing.
TODO’s¶
Todo
Class does not allow for lambda function for h. Thus, the colors
on both ends of a qualitative color map with h = [0, 360]
are
identical. See also palette definition (text files). I would need
to allow for lambda functions which will require quite some adaptions
of the current code (reading config files; _checkinput function; evaluation
of the function whenever needed).
Just adding lambda. Write tests for this.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/colorspace/palettes.py:docstring of colorspace.palettes.qualitative_hcl, line 57.)
Todo
Article about color map approximations must be written or referred to the R colorspace website.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/articles/approximations.rst, line 9.)
Todo
Incorrect description. Missing support for the lambda function which, here,
controls h2
by default. Once implemented please check code/result/text.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/articles/hcl_palettes.rst, line 109.)
Todo
I do not have the same order as I do not mix basic and advanced. Thus, this list above is invalid for the python package. Fix this.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/articles/hcl_palettes.rst, line 258.)
Todo
Registering new palettes not yet implemented.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/articles/hcl_palettes.rst, line 427.)
Todo
Section must be written.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/articles/palette_visualization.rst, line 208.)
Todo
Darken and lighten not yet implemented.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/getstarted.rst, line 64.)
Todo
Update once released on PyPI.
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/getstarted.rst, line 117.)
Todo
Adjust text when adding divergingx_hcl() (_Finally, even more flexible diverging HCL palettes are provided by divergingx_hcl()
(The original entry is located in /home/runner/work/python-colorspace/python-colorspace/source/getstarted.rst, line 154.)