PRP PRP - 2 months ago 13
R Question

Plotting a heatmap of temperatures

I have a matrix of which a smaller version looks like this

318.3 318.3 318.3
318.3 318.3 318.3
318.3 318.3 318.3

These are the temperatures of a grid of processors. I want to plot a heat map by assigning regular colors i.e. blue to cool and red to hot cores.

An example of what I am looking for is :

enter image description here

How do I do this using a program or is there any software for linux which does this ?

42- 42-

Looks like the rainbow palette could be used with image

m <- matrix(c(1, 1,1,1,1,1,1,
1,1,1,1,1,1, 1), 5,7, byrow=TRUE)

image(m, col=rev(rainbow(100))[ 70:100]) # need to reverse it to have high values red.

(The heatmap functions generally are dolled-up versions of image.)

With the file (that doesn't have much variation) you can get results after reading in the file without a header, removing the column of NA's and coercing to a matrix:

 image( f, col=rev(rainbow(350))[ 270:350])

enter image description here

Can also use lattice::levelplot with the obviousl advantage that you get a scale automagically:

levelplot(f, col.regions=rev(rainbow(350))[ 270:350])

enter image description here