Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用knitr::include_图形的图形大小块选项被忽略_R_Knitr - Fatal编程技术网

使用knitr::include_图形的图形大小块选项被忽略

使用knitr::include_图形的图形大小块选项被忽略,r,knitr,R,Knitr,给定以下r标记文件: ```{r} library(knitr) ``` ```{r, out.width="100%"} path <- "plotx.png" knitr::include_graphics(path) ``` ```{r, out.width="100%", out.height="150%"} knitr::include_graphics(path) ``` 对于HTML输出,设

给定以下
r标记文件:

```{r}
library(knitr)
```

```{r, out.width="100%"}
path <- "plotx.png"
knitr::include_graphics(path)
```

```{r, out.width="100%", out.height="150%"}
knitr::include_graphics(path)
```

对于HTML输出,设置
out.width=“100%”
会将图像缩放到其父容器的100%宽度,而不是图像像素的100%。Therby保持纵横比,在不失真的情况下提供最大可能的结果。因此,设置
out.width=“100%”和
out.height=“150%”
会产生相同的结果。使用像素获得精确的尺寸(这可能会导致失真)

对于LaTeX输出,纵横比保持不变,无论您使用像素还是%(唯一的区别是像素被视为像素,并且%被转换为缩放因子,以
\textheight
\linewidth
)。您可以使用chunk选项
out.extra='keepaspectratio=false'
来防止这种情况

示例:

来自的图像

---
标题:“无标题”
输出:
html_文档:默认值
pdf_文档:默认值
---
乳胶和HTML:宽度=100px,宽高比保持不变

`{r,out.width=“100px”}
老虎