Here's how to do it. These are very hacks, but I think that when a function does not do what you want to do, the best solution is to force it to do it anyway.
The heatmap.2 function contains three lines in the middle of the code:
... op <- par(no.readonly = TRUE) on.exit(par(op)) layout(lmat, widths = lwid, heights = lhei, respect = FALSE) ...
Because of them, you cannot use layout and par(mar=...) since it overrides it. Copy the heatmap.2 code into a new function (say heatmap.3 ) and delete these three lines:
heatmap.3 <- function(...
Then your code for creating your two heat maps will be, for example:
layout(rbind(c(4,3,8,7),c(2,1,6,5)), widths = c(1,2,1,2), heights = c(1,2), respect = FALSE) heatmap.3(x) heatmap.3(y)
When preparing the layout, remember that in terms of the heat dissipation map, first the heat map itself is displayed, then the dendrogram "row", then the dendrogram "col" and, finally, the histogram, therefore, the order is from top to bottom, from left to right - 4, 3, 2, 1 when both heat cards side by side become 4, 3, 8, 7, 2, 1, 6, 5.