I have an array of temperatures given a certain position.
EG:
20 21 22 23 20
20 22 21 23 20
20 21 20 20 20
20 21 23 23 23
21 21 22 23 22
The top right data point represents the temperature in the top right heatmap, while the bottom left - represents the bottom left temperature of the heatmap I want to produce.
So taken these data points how would I produce a HeatMap where higher temperatures are more RED and cooler are more blue.
Should I first convert the temperatures into RGB and then somehow plot the RGB? how can I do this?
EDIT: Top right (in this case 20) of the array or [0,0] represents the temperature at [0,0] in space. The 2d heatmap I want to produce represents an image infront of a temperature camera. The data points are the temperatures at certain locations. The posting is not too helpful because it is based on frequency and not converting temperature to color and plotting it based on position.
You could use Python's built-in
tkinter
graphics module to do something like the following. Thepseudocolor()
function maps a value in given range to a color interpolated along those in a palette of arbitrary color values. The auxiliarycolorize()
function exists to convert color values returned from it — which consist of three floating-point values in the range 0 to 1 — into the single hex-string form required bytkinter
.Since the selection of colors is controlled by a list of color values, it's fairly easy to tweak how the output looks. The example heatmap is relatively small as is the range of values in it, so the image produced is a little "chunky" looking — but the approach scales well and more attractive results would likely be derived from larger and more varied datasets.
Display: