我正在使用r markdown和Rstudio来创建html报告。 我有一些图形,我希望非常宽,但是,即使在块选项中使用fig.width
和out.width
,输出中的宽度似乎也有限制。 例如,以下三个代码块在最终输出中生成宽度相同的图形:
```{r,fig.height=7,fig.width=12,echo=FALSE}
plot(rnorm(1000),type="l")
```
```{r,fig.height=7,fig.width=40,echo=FALSE}
plot(rnorm(1000),type="l")
```
```{r,fig.height=7,fig.width=40,echo=FALSE,out.width=20000}
plot(rnorm(1000),type="l")
```
我已经使用 options(width=LARGENUMBER)
进行输出(例如 print
等),这似乎适用于打印表格,但我还没有找到一种方法来使这些图形更宽。
有什么建议吗?
你可以添加这样的东西
---
output: html_document
---
<style>
img {
max-width: none;
/* other options:
max-width: 200%;
max-width: 700px;
max-width: 9in;
max-width: 25cm;
etc
*/
}
</style>
```{r,fig.height=7,fig.width=12,echo=FALSE}
plot(rnorm(1000),type="l")
```
```{r,fig.height=7,fig.width=40,echo=FALSE}
plot(rnorm(1000),type="l")
```
```{r,fig.height=7,fig.width=40,echo=FALSE}
plot(rnorm(1000),type="l")
```
或者更好的是设置你的 knitr.css 文件
img {
max-width: 200%;
}
或任何你喜欢的东西,并使用
---
output:
html_document:
css: ~/knitr.css
---