I have multiple heat maps similar to the following:
X <- matrix(nrow=3, ncol=3)
X[1,] <- c(0.3, 0.4, 0.45)
X[2,] <- c(0.3, 0.7, 0.65)
X[3,] <- c(0.3, 0.4, 0.45)
colnames(X)<-c(1.5, 3, 4)
rownames(X)<-c(1.5, 3, 4)
library(gplots)
heatmap.2( X, Rowv=NA, Colv=NA, col=rev(heat.colors(256)),
sepcolor="black", trace="none",dendrogram="none" )
Now, in order to make multiple plots of this kind look more similar, how can I get the upper left histogram to always go between 0 and 1?
Based on yuk's answer I made this version:
X <- matrix(nrow=3, ncol=3)
X[1,] <- c(0.3, 0.4, 0.45)
X[2,] <- c(0.3, 0.7, 0.65)
X[3,] <- c(0.3, 0.4, 0.45)
colnames(X)<-c(1.5, 3, 4)
rownames(X)<-c(1.5, 3, 4)
library(gplots)
colors <- rev(heat.colors(256))
colbr <- c(seq(0, 1, len=length(colors)+1))
heatmap.2(X, scale="none", col=colors, breaks=colbr,
key=T, symkey=F, density.info="histogram", trace="none", Rowv=NA, Colv=NA,
sepcolor="black", dendrogram="none" )
Now the color scale goes between 0 and 1 bit the histogram does still not.
I think the best way is to set color breaks.
Here is what i usually do (
x
is the matrix for heatmap):