Using the heatmap.2
function in gplots
package, fortunately this can be done more easily. First load in some test data:
my.image <-
structure(c(0.284887135194186, 0.0266252817250525, 0.348431746937973,
0.746492464670314, 0.267235059081902, 0.0209642747046111, 0.378676942016667,
0.607990837304665, 0.312847060269367, 0.612395191587952, 0.483024535963144,
0.564162902506238, 0.128115012083734, 0.548085047655703, 0.614939304016718,
0.51253667320726, 0.591278116015954, 0.395201893060755, 0.682934039875973,
0.416956130236154, 0.677632422556141, 0.385639902518959, 0.692257324851365,
0.358990284723972, 0.224435642972774, 0.376108601670825, 0.717444067668913,
0.308920663224123, 0.149392034309146, 0.399379225875787, 0.158378066789988,
0.0536693928847938, 0.049487973904056, 0.54274177846382, 0.0398607307385965
), .Dim = c(7L, 5L), .Dimnames = list(c("row1", "row2", "row3",
"row4", "row5", "row6", "row7"), c("col1", "col2", "col3", "col4",
"col5")))
Then plot the heatmap, preserving the row and column order:
library(gplots)
heatmap.2(my.image, density.info="none", trace="none", dendrogram='none',
Rowv=FALSE, Colv=FALSE)
The image looks like this:

This article by Sebastian Rashka is also very helpful for producing heatmaps that actually look good: http://sebastianraschka.com/Articles/heatmaps_in_r.html