Color scales in Python for humans

Working with colors in Python is confusing:

  • colorsys requires 0-1 decimal RGB / HSL / HSV values, and works only with single colors
  • matplotlib is heavy if you only want color conversion and interpolation
  • Cynthia Brewer’s popular color scales aren’t easily available through a pip library
  • Colors are often not displayed in formats that work with modern css
  • In IPython notebook, there are no intuitive, lightweight tools to quickly inspect color scales

… Introducing colorlover, a web-friendly color conversion and interpolation library.

To install:

Here’s an example of using colorlover in IPython notebook:


Colors are displayed in RGB string format by default:

['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']

And its easy to change to other color models:

['hsl(19.0, 96.0%, 67.0%)', 'hsl(60.0, 100.0%, 87.0%)', 'hsl(203.0, 51.0%, 71.0%)']

colorlover is ideal for charting with Plotly:

See this IPython notebook for full usage.

Documentation and code is hosted on GitHub.

Inspiration and color scales in cl.scales from Cythnia Brewer’s ColorBrewer.