I draw a double matrix 759 * 12 twoway.expr.005 using a heat map .2 ()
library(gplots) dist2 <- function(x, ...){as.dist(1-cor(t(x), method="pearson"))} heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F)
But because I set dendrogram='row' (the dendrogram column is off) and key=F , my heatmap leaves huge gaps between the plot title and the actual plot when I try to save it as a PDF.

I tried to install lhei as suggested. I used lhei = c (1,4), but it still shows me a space between the title and the plot:
heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F,lhei=c(1,4))

Setting lhei = c (1,5) completely discards the name:
heatmap.2(x=twoway.expr.005,col=bluered(75), main="Heatmap:759 genes\nTwosided Pval<0.05",tracecol= NULL, cexCol=0.8,cexRow=0.5,labCol=labs,distfun=dist2,scale="row",key=F,dendrogram='row',Colv=F,lhei=c(1,5))

I think Heatmap.2 is designed in such a way that the header is always placed above the column dendrogram. Therefore, if a column dendrogram is disabled, it leaves blank space, but the header position is still above the disabled column dendrogram. Is there a way to crack the code so that the header is not placed above the column dendrogram (which could be the solution to this problem)? What else can be done to remove the space between the title and the actual plot?