mercredi 15 juin 2016

Darken or lighten a color in matplotlib


Say I have a color in Matplotlib. Maybe it's a string ('k') or an rgb tuple ((0.5, 0.1, 0.8)) or even some hex (#05FA2B). Is there a command / convenience function in Matplotlib that would allow me to darken (or lighten) that color.

I.e. is there matplotlib.pyplot.darken(c, 0.1) or something like that? I guess what I'm hoping for is something that, behind the scenes, would take a color, convert it to HSL, then either multiply the L value by some given factor (flooring at 0 and capping at 1) or explicitly set the L value to a given value and return the modified color.


Aucun commentaire:

Enregistrer un commentaire