Assuming values are normalized from 0 to 1, what is the algoritm to get a color to create a heatmap like this?
1 is red, .5 is green, 0 is dark blue.
Working in
Here's a simple 5 color heatmap in python (in pyqt, but easy to generalize)
def genColorMap(self):
points = [(255,0,0), (255,255,0), (0,255,0), (0,255,255), (0,0,255)]
cm = {}
for i in range(0, 256):
p0 = int(numpy.floor((i/256.0)/len(points)))
p1 = int(numpy.ceil((i/256.0)/len(points)))
rgb = map(lambda x: x[0]*max(0,(i-p0)) + x[1]*max(0,(i-p1)), zip(points[p0], points[p1]))
cm[i] = QtGui.qRgb(rgb[0], rgb[1], rgb[2])
return cm