R – pheatmap formatting in R: Legend size and creating a square plot

formattingheatmappheatmapr

Pheatmap only creates a square plot when legend=FALSE. I have tried using par() to allow more oma() and mar() space without luck. The legend is also really big and i cannot find any documentation on reducing this or changing its position. The first plot doesn't have a dendrogram fitted but this is irrelevant to the sizing issue. The same happens regardless of the clustering. I would appreciate any comments

png(filename="tmpfile.png", width=1500, height=1500, res=500)
pheatmap(res, cluster_rows=FALSE, cluster_cols=FALSE, main="Default_clust", annotation=res2, color = rainbow(n, start=.7, end=.1), show_rownames=FALSE, show_colnames=FALSE, border_col=NA, fontsize=6)
dev.off()

Square plot with no legend
plot has legend but is not square

Best Solution

The question about square plot is actually quite relevant for plotting Pearson correlations. I came here hoping for an answer, in the end I came up with a workaround to set the cell width manually, eg:

pheatmap(...,     
cellheight=3, cellwidth = 3)

But I would like a better way.

Related Question