简体   繁体   English

"自动调整大图以适合 rmarkdown 的页面 pdf 输出"

[英]Automatically adjust large plots to fit page pdf output from rmarkdown

I am having issues when knitting my rmarkdown file to PDF with large plots.将我的 rmarkdown 文件编织成带有大图的 PDF 时遇到问题。 The plots get cut when producing the PDF file.生成 PDF 文件时,绘图会被剪切。

The problem is that I can't find a way to automatically adjust the height and width of all the plots.问题是我找不到自动调整所有图的高度和宽度的方法。 As I am writing a very large report, I have several plots like this, thus adjusting them separately (through fig.width and fig.height) is out of question.当我正在写一个非常大的报告时,我有几个这样的图,因此单独调整它们(通过 fig.width 和 fig.height)是没有问题的。

Is there any package\/command that I should use in my YAML or preamble.tex file?我应该在我的 YAML 或 preamble.tex 文件中使用任何包\/命令吗?

Minimal reproducible example:最小的可重现示例:

---
output: pdf_document
---

## Large Plot

```{r}
library(meta)

data(Fleiss93)

##
m <- metabin(event.e, n.e, event.c, n.c,
              data = Fleiss93, studlab = study,
              sm = "RR", method = "I")

forest(m)
```

To change default settings, put the following code chunk early in your document:要更改默认设置,请将以下代码块放在文档的前面:

```{r include = FALSE}
knitr::opts_chunk$set(fig.height = 9, fig.width = 7)
```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM