在R中并排显示两个pdf的热图 [英] to display two heatmaps in same pdf side by side in R

查看:302
本文介绍了在R中并排显示两个pdf的热图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在同一png或pdf中并排显示两个或更多热图.在这种情况下,布局或mfcol不起作用.有人可以帮我这个忙吗.

i am trying to display two or more heatmaps side by side in the same png or pdf . The layout or mfcol is not working in the case. Can someone please help me out with this.

推荐答案

以下是使用最近引入的gridGraphics软件包的一种选择,

Here's one option using the recently introduced gridGraphics package,

library(gridGraphics)
library(grid)
heatmap(as.matrix(mtcars))

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

g <- grab_grob()
grid.newpage()

# library(gridExtra)
# grid.arrange(g,g, ncol=2, clip=TRUE)

lay <- grid.layout(nrow = 1, ncol=2)
pushViewport(viewport(layout = lay))
grid.draw(editGrob(g, vp=viewport(layout.pos.row = 1, 
                                  layout.pos.col = 1, clip=TRUE)))
grid.draw(editGrob(g, vp=viewport(layout.pos.row = 1, 
                                  layout.pos.col = 2, clip=TRUE)))
upViewport(1)

这篇关于在R中并排显示两个pdf的热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆