A Python 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
- Color spaces
- HCL-Based Color Palettes
- HCL-Based Color Palettes for matplotlib, seaborn, and plotly
- Palette Visualization and Assessment
- App for Choosing Palettes Interactively
- Color Vision Deficiency Emulation
- Color Manipulation and Utilities
- Approximate Colors from Other Packages
- Somewhere over the Rainbow
Community guidelines
Everyone is warmly welcome to contribute to Python colorspace by addressing existing issues, reporting bugs, or requesting new features. Please refer to our Community guidelines for more information.
Citations
Stauffer, R. and Zeileis A. (2024). “colorspace: A Python Toolbox for Manipulating and Assessing Colors and Palettes.” The Journal of Open Source Software, 9(102), 7120, doi:10.21105/joss.07120.
Stauffer, R. and Zeileis, A. (2024). “colorspace: A Python Toolbox for Manipulating and Assessing Colors and Palettes (v1.0.0)”. Zenodo. doi:10.5281/zenodo.14004295.
Other packages 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: doi: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. American Meteorological Society, 96(2), 203–216, doi:10.1175/BAMS-D-13-00155.1. Zeileis, Achim, Kurt Hornik, and Paul Murrell. 2009. “Escaping RGBland: Selecting Colors for Statistical Graphics.” Computational Statistics & Data Analysis 53: 3259–3270. https://doi.org/10.1016/j.csda.2008.11.033.
- Ihaka, Ross. 2003. “Colour for Presentation Graphics.” In Proceedings of the 3rd International Workshop on Distributed Statistical Computing, Vienna, Austria, edited by Kurt Hornik, Friedrich Leisch, and Achim Zeileis. https://www.r-project.org/conferences/DSC-2003/Proceedings/Ihaka.pdf.
- Crameri, Fabio, Grace E. Shephard, and Philip J. Heron. 2020. “The Misuse of Colour in Science Communication.” Nature Communications 11 (5444): 1–10. https://doi.org/10.1038/s41467-020-19160-7.
- … and others (reference list).
Some other packages providing color maps in Python wich might be of interest:
- matplotlib: Library for creating visualizations. Provides a range of (mostly) well specified color maps colormaps.
- seaborn: Statistical data visualization. The package also provides access to a range of (mostly) well specified color palettes.
- plotly: Graphing library for interactive plots and figures which comes with a series of built-in and (mostly) well defined color scales.
- palettable: Color palettes for Python. Formely known as
brewer2mpl
. Provides a range of color palettes including “Brewer2” and “Carto” palettes. - cmcrameri: Python package with a few series of sequential and diverging color palettes.
- colormap: Python package providing access to a series of color palettes and functionality to create own (fixed-color) palettes.
- colormaps: Collection of color palettes for Python to be used with matplotlib (e.g., cartocolors, brewer palettes, …).
- ColorBrewer2.org: The source of the brewer colors, interactive web page by Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.