# Create heat map from RMSD values

After looking through these forums for answers that could work for my problem, I could not find anything. I want to make a heat map comparing values that are in a nested list. That is, I have a nested list of size n x n, and each position in the list is a rational number. How could I make a heat map comparing the greater/lesser of these numbers. The higher numbers would be one color and the lower would be another.

An example first three lines of a list of Length 9 is:

{{0., 2.03181, 10.9162, 9.81852, 19.9333, 9.74689, 0.826292, 1.61575,
6.11642}, {2.52762, 0., 12.3072, 13.0194, 5.9971, 20.1544, 2.1197,
0.611078, 5.01625}, {17.5098, 6.42256, 0., 5.32809, 7.09947,
22.5269, 5.43391, 5.56034, 0.48698}}


All assistance is appreciated.

Best,

CK

-
Would ArrayPlot@yourList work? – Mike Honeychurch Feb 14 '13 at 4:14

This is in the docs* and might be what you want:

(* the catch is you have to know that this is what you need to be able to find it in the docs -- it is not necessarily intuitive for a new user to go to array plot for this solution)

or you can blend between two colours:

ArrayPlot[RandomReal[1, {10, 20}], ColorFunction -> (Blend[{Yellow, Purple}, #1] &)]


or make a binary choice:

ArrayPlot[{{0., 2.03181, 10.9162, 9.81852, 19.9333, 9.74689, 0.826292,
1.61575, 6.11642}, {2.52762, 0., 12.3072, 13.0194, 5.9971,
20.1544, 2.1197, 0.611078, 5.01625}, {17.5098, 6.42256, 0.,
5.32809, 7.09947, 22.5269, 5.43391, 5.56034, 0.48698}},
ColorFunction -> (If[#1 > 10, Purple, Yellow] &),
ColorFunctionScaling -> False]


ColorFunctionScaling is an option that by default is True and means that the values in your list are scaled. There may be occasions where you want to apply your own scaling function. You would do this as a pure function for ColorFunction.

Here is default scaling using a "wimbledon" gradient (green-purple)

ArrayPlot[{{0., 2.03181, 10.9162, 9.81852, 19.9333, 9.74689, 0.826292,
1.61575, 6.11642}, {2.52762, 0., 12.3072, 13.0194, 5.9971,
20.1544, 2.1197, 0.611078, 5.01625}, {17.5098, 6.42256, 0.,
5.32809, 7.09947, 22.5269, 5.43391, 5.56034, 0.48698}},
ColorFunction -> (Blend[{Green, Purple}, #1] &),
ColorFunctionScaling -> True]


Here is a new plot, this time scaling your numbers between 0 and 40.

ArrayPlot[{{0., 2.03181, 10.9162, 9.81852, 19.9333, 9.74689, 0.826292,
1.61575, 6.11642}, {2.52762, 0., 12.3072, 13.0194, 5.9971,
20.1544, 2.1197, 0.611078, 5.01625}, {17.5098, 6.42256, 0.,
5.32809, 7.09947, 22.5269, 5.43391, 5.56034, 0.48698}},
ColorFunction -> (Blend[{Green, Purple}, Rescale[#1, {0, 40}]] &),
ColorFunctionScaling -> False]


-
Thanks so much!! – Chirese Feb 14 '13 at 15:36