Nifty use of a heat map to show change over time
All code in this post is for R. To make heat maps, I will use the function heatmap_2 from the Heatplus package, which comes from the Bioconductor library. At the time I used it (several months before this post), Bioconductor R packages had a strange installation system (not the usual CRAN modules). So I installed the package as follows:
source("http://bioconductor.org/biocLite.R")
biocLite("Heatplus")
You can use your favorite heat map function. On to the niftyness.
If you want to show observations over time, you can plot them:
d=log(seq(from=.05, to=2, by=.01)) plot(d, xlab="time", ylab="value")
Resulting in:

But what to do with many subjects?
set.seed(789478547)
subjects=50
f=function(){sample(c(-1,1), 1) * d*runif(1,.01,2)+runif(1,1,2)}
many = t(replicate(subjects, f(), simplify=TRUE))
Here we have the matrix “many”, where each row is a transform of a the above logarithmic data. Let’s say each row is observations over time, for one subject. The rows have been transformed, so some are increasing, some are decreasing and all at different rates. We would like to visualize this set of observations.
There are 50 rows in this matrix and we could plot each row, all overlaid on the same x/y axis. I’ll not bother doing this, because the result is a mess. Even if we use lines rather than points, and give each line a unique color, we get a mess.
So how about this:
library(Heatplus) heatmap_2(many, col=rainbow(length(d)), Rowv=NA, Colv=NA, do.dendro=c(FALSE,FALSE), scale="none", legend=2, main="Observations over time")
Resulting in this:
In this “heat map”, each row is a subject and the x-axis is time (flowing from left to right). I’m sure the colors could be better, but hopefully the more you look at this, the more information you see. I think this image describes the data in a very intuitive way.
I applied this technique to data where some subjects showed a trend over time and some didn’t. I could easily distinguish subjects with a strong trend from subjects with no trend. I will probably use this again in the future, although hopefully I’ll find a heat map function that is more suited to this kind of application.

[...] October 2, 2009 Here’s an interesting visualization of daily stock returns for 50 components of the S&P 500. I used the same kind of heat map plot from my previous post. [...]
[...] this article, Hans Gilde exposes the clever use of a heatmap hidden in the Bioconductor library. In his example, [...]