Skip to content

Instantly share code, notes, and snippets.

@zxf8665905
Created May 11, 2018 04:10
Show Gist options
  • Save zxf8665905/962e33878f5a5e23205ea79b0e967396 to your computer and use it in GitHub Desktop.
Save zxf8665905/962e33878f5a5e23205ea79b0e967396 to your computer and use it in GitHub Desktop.
get heatmap rgb
def heat_map_rgb(minimum, maximum, value):
minimum, maximum = float(minimum), float(maximum)
ratio = 2 * (value-minimum) / (maximum - minimum)
b = int(max(0, 255*(1 - ratio)))
r = int(max(0, 255*(ratio - 1)))
g = 255 - b - r
return (r, g, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment