I tried to generate a heatmap using heatmap.2
in gplots
package. My aim is to generate a heatmap with no extra space between plot area and heatmap (excluding the key at the bottom). By looking at some posts, I managed to fit heatmap to plot area using lmat
(so that there are no space at left part). But I cannot center the color key below the plot. As a result, there is some space because of the projected a color scale scale at the right side.
Can anyone tell me how to make the color key at the center of the heatmap at bottom part (thus to avoid extra space problem).
I am unable to show the image. I use following code to generate heatmap.
library(gplots)
dat <- read.csv("C:..../xxx.csv")
dat_matrix <- data.matrix(dat)
colors = c(seq(-2,-1,length=100),seq(-1,1,length=100),seq(1,2,length=100))
my_palette <- colorRampPalette(c("green","black","red"))(n = 299)
lmat = rbind(c(1,3),c(2,1),c(1,4))
lwid = c(1,4)
lhei = c(1,4,1.2)
heatmap.2(dat_matrix, dendrogram="none", Rowv = FALSE, Colv = FALSE,
col = my_palette, breaks = colors, scale = "none", key = TRUE,
density.info = "none", trace = "none", labRow = FALSE, symm = FALSE,
symkey = TRUE, symbreaks = TRUE, lmat = lmat, lwid = lwid, lhei = lhei)