wvoq
wvoq

Reputation: 573

Why doesn't R's heatmap function color cells consistently?

The heatmap function in R is supposed to help a human being interpret the relative values of the elements of a matrix. However, it seems not to color cells consistently within a given plot, which is a severe obstacle to interpreting the relative values correctly.

For example, let's generate some data by concatenating columns of normal random variates:

foo <- cbind(replicate(10,rnorm(10)))

Now if we correlate the columns of foo, we can verify that we get 1's in the diagonal entries since the correlation of any column with itself is 1:

cor.matrix <- cor(foo)

But when we plot:

heatmap(cor.matrix,Rowv=NA,Colv=NA)

(we're suppressing the dendrogram reording here, although that doesn't seem to matter)

the diagonal cells are not colored uniformly, as you can see: here

Can anyone explain what's happening here?

Upvotes: 5

Views: 777

Answers (1)

IRTFM
IRTFM

Reputation: 263332

By default heatmap scales by "row".

heatmap(cor.matrix,Rowv=NA,Colv=NA, scale="none")

Upvotes: 7

Related Questions