Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generate text color depending on the heat-map value
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
You can’t perform that action at this time.