Multiple Heatmap plot in one canvas with mfrow?
1
2
Entering edit mode
8.5 years ago
Shicheng Guo ★ 9.5k

Hi All,

Any solution to plot multiple heatmap in one page in R (heatmap.2 in gplots)? par(mfrow=c(2,2)) don't work. It will plot the heatmap in separate pages.

Thanks.

heatmap mfrow • 12k views
ADD COMMENT
5
Entering edit mode
8.5 years ago
Shicheng Guo ★ 9.5k

I find the solution eventually, Anyway, share with others, hope it is helpful in your routine analysis. Also, I found gridGraphics and grid is very useful for complicated figure preparation.

library(gridGraphics)
library(grid)

grab_grob <- function(){
  grid.echo()
  grid.grab()
}

data<-read.table("heatmap.input.matrix.data.txt")

library(gplots)
gl <- lapply(1:ncol(data), function(i){
  heatmap.2(data.matrix(data[[i]]))
  grab_grob()
})

grid.newpage()
library(gridExtra)
grid.arrange(grobs=gl, ncol=5, clip=TRUE)
ADD COMMENT
2
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 1885 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6