What is the algorithm to create colors for a heatmap?

后端 未结 6 1515
你的背包
你的背包 2021-01-30 10:31

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

6条回答
  •  一生所求
    2021-01-30 11:23

    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
    

提交回复
热议问题