3
私はmetaforを使って各繰り返しでフォレストグラフを生成するRループを持っています。フォレストグラフにはサンプルあたり1行があり、繰り返しごとにサンプル数が異なるため、高さをかなり変える必要があります(現在は2.5〜8インチ)。Knitrは同じ塊で図形のサイズが異なります
私はのようないくつかのオプションを試しましたが、私が作成した各グラフィックは.pdfファイルの出力に同じ高さを持っています(単にファイルを正方形にするようです)。マージンの上下。
カスタムグラフィックデバイスhereのノートも見つかりましたが、チャンクの途中でグラフィックデバイスを変更する方法はわかりません。私は単に各ループの反復でopts_chunk$set(fig.width=fheight)
を使用しようとしましたが、運はありませんでした。
MWE
\documentclass{article}
\begin{document}
<<Mwe, echo=FALSE, results = 'asis', message='FALSE', fig.width=7,warning='FALSE'>>=
heights <- c(2.5, 8)
for(counter in 1:length(heights)) {
opts_chunk$set(fig.height=heights[counter]) #This doesn't appear to change anything
par(fin=c(7, heights[counter]) #this makes the plot have the correct height, but I get a 2.5 inch high plot vertically centered in a 7 inch high pdf.
hist(rnorm(100))
cat("Some long text which describes a lot of stuff about this graphic before making a new subsection for the next one")
}
@
\end{document}