Last active
April 16, 2018 02:45
-
-
Save hanneshapke/cd2670f2264d68023b0f6882a90a0f76 to your computer and use it in GitHub Desktop.
Generate text color depending on the heat-map value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def color(hvalue, threshold, max=1, cdefault='black', colors=['red', 'yellow', 'green', 'cyan', 'blue']): | |
num_colors = len(colors) | |
if hvalue < threshold: | |
return cdefault | |
for i, color in enumerate(colors): | |
if hvalue > (max - (max - threshold) / num_colors * (i + 1)): | |
return color |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment