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
Linear interpolation of the RGB components works quite well in practice, and the link Bruno shared mentions doing your interpolation in HSL which can help.
You can also intersperse your three basic colours with more nicely chosen intermediates. Check out http://colorbrewer2.org/ for some good colour progressions. Then break up your steps further:
0 red
0.25 yellow
0.5 green
0.75 cyan
1 blue