Colors are difficult, especially if you don't have a good eye for design.
Most of us tech professionals don't. The advantage is that Python can do most of the heavy lifting for you. You can generate a complete monochrome color palette that will look stunning in any stacked chart.
The downside is that getting there requires quite a bit of coding. You must write custom functions to convert a color from HEX to HSL and back, and determine whether the initial color is too bright, as well as how much lighter each following color should be.
To add insult to injury, I have not found a single fully functional Python library capable of accomplishing this task.
That's where this article comes in.
if you are a subscriber to my Substackyou can skip reading and download the notebook instead.
Let's quickly cover three color formats you need to know:
- HEX — A six-digit code typically used in web development and graphic design. The color code starts with a
#
followed by six hexadecimal digits. Peers…