0

我正在尝试使用以下代码将两个数字绘制到一个 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)
}
4

1 回答 1

2

底行的视口被推入顶行的视口。首先弹出顶行的视口似乎可以解决问题。

注意:对于视口来说,这是一个非常常见的错误,所以如果它发生在您身上,请不要感到难过。

于 2013-04-01T19:25:43.000 回答