knitr HTML中非常宽的图形

Ric*_*ich 2 html css r knitr r-markdown

我正在使用r markdown和Rstudio来创建一个HTML报告.我有一些我想要非常宽的图形,但是,即使使用fig.widthout.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")
```
Run Code Online (Sandbox Code Playgroud)

我已经用于options(width=LARGENUMBER)输出(例如print,等等),这似乎适用于打印表,但我还没有找到一种方法来使这些图表更宽.

有什么建议?

raw*_*awr 5

你可以添加这样的东西

---
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")
```
Run Code Online (Sandbox Code Playgroud)

或者更好地设置你的knitr.css文件

img {
    max-width: 200%;
}
Run Code Online (Sandbox Code Playgroud)

或者你喜欢什么,并使用

---
output: 
  html_document:
    css: ~/knitr.css
---
Run Code Online (Sandbox Code Playgroud)