完成相同代码块中的绘图并在使用mfcol

时间:2017-10-14 00:47:54

标签: r knitr

knitr使用par mfcol参数有多个时,--- title: "Untitled" author: "Not me" date: "October 14, 2017" output: html_document --- ```{r} set.seed(73856421) # Plot random number of graphs par(mfcol = c(2, 2)) for(i in 1:sample.int(6, 1)) # not in control of the number of plots here plot(rnorm(100)) # <-- want plot here # ... # some other code # .... # plot new results plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1)) text(.5, .5, "should be") plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1)) text(.5, .5, "together") plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1)) text(.5, .5, "in new") plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1)) text(.5, .5, "4x4 plot") ``` 是否有办法在代码块中完成绘图并开始新的绘图同一情节中的数字。我的代码大致类似于

# <-- want plot here

问题在于,第一个4x4图未显示在plot.new,并且其中有两个下一个数字。到目前为止,我最好的解决方案是跟踪数字的数量,并使用framevar defs = svg.append('defs'); defs.append("pattern") .attr("x", 0) .attr("y", 0) .attr("id", "myPattern")//ID here .attr("width", 12) .attr("height", 12) .append("image") .attr("xlink:href", 'https://assets-cdn.github.com/images/modules/open_graph/github-octocat.png') .attr("width", 12) .attr("height", 12) .attr("x", 0) .attr("y", 0); 为#34;缺少&#34;数据。虽然在我目前的设置中这比上述更复杂,但这是一个单调乏味的事情。

0 个答案:

没有答案