4

I am trying to do multipanel plots one panel being a heatmap using layout to place plots. I've been drawing heatmaps with pheatmap which provides a very convenient color scheme among other things.

The code for pheatmap is available here.

When I try using pheatmap in this way it always plots on a new page. I imagine this is because of its use of the grid package? Is there a way I can do this with pheatmap?

Example code to produce a heatmap next to a barplot but which doesn't since the heatmap gets plotted on a new page below:

xlay=layout( matrix(c(2,2,1),nrow=1) )
layout.show(xlay)
barplot(rnorm(8),horiz=T)
pheatmap(matrix(rnorm(80),nrow=8))
4

1 回答 1

5

在 ggplot 中制作条形图

bar <- ggplot()  

将条形图和热图都分配给一个变量

heat <- pheatmap(matrix(rnorm(80),nrow=8))

然后使用gridExtra包制作面板图热图保存为对象,您可以通过评估对象中的第 4 项再次绘制它

grid.arrange(bar, heat[[4]], nrow = 1)
于 2019-06-25T05:50:16.660 回答