我正在尝试使用以下代码将两个数字绘制到一个 PDF 上:
ncols <- 1
nrows <- 2
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrows, ncols)))
for (i in seq_along(chroms)) {
pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
plotTracks(list(itrack, gtrack, dTrack),
chromosome = chr1, add = TRUE)
pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 2))
plotTracks(list(biomTrack, gtrack2),
chromosome = chr1, add = TRUE)
popViewport(1)
}
问题是,这两个数字重叠了!(并且图中的row2仍然是空的)
我希望新鲜的眼睛会抓住我的错误。我究竟做错了什么?
编辑以反映@DINRE 的评论
ncols <- 1
nrows <- 2
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrows,
+ ncols)))
for (i in seq_along(chroms)) {
pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
plotTracks(list(itrack, gtrack, dTrack),
chromosome = chr1, add = TRUE)
**popViewport(1)** ## NEED TO POP OUT FIRST ROW BEFORE PLOTTING SECOND.
pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 2))
plotTracks(list(biomTrack, gtrack2),
chromosome = chr1, add = TRUE)
popViewport(1)
}