Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active November 23, 2019 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cderv/a3926f55f92b869d877a5f2a5fb2cc4e to your computer and use it in GitHub Desktop.
Save cderv/a3926f55f92b869d877a5f2a5fb2cc4e to your computer and use it in GitHub Desktop.
Test for knitr issue on include_graphics (https://github.com/yihui/knitr/pull/1776)
# one graphic
```{r, fig.cap = "This is a caption for unique figure"}
knitr::include_graphics("test-1.png")
```
# Three graphics in the same chunk
Using three times `include_graphics`
```{r, fig.cap = "This is a caption", out.width = "33%", fig.show = "hold"}
knitr::include_graphics("test-1.png")
knitr::include_graphics("test-2.png")
knitr::include_graphics("test-3.png")
```
```{r, fig.cap = "This is another caption", out.width = "33%", fig.show = "hold"}
knitr::include_graphics(c("test-1.png", "test-2.png", "test-3.png"))
```
# mixing with plot
```{r, fig.cap = "This is a caption", out.width = "33%", fig.show = "hold"}
knitr::include_graphics("test-1.png")
plot(iris)
knitr::include_graphics("test-2.png")
1+1
knitr::include_graphics("test-3.png")
```
```{r, fig.cap = c("This is a caption", "This is another", "this is a plot", "And a last"), out.width = "33%"}
knitr::include_graphics(c("test-1.png", "test-2.png"))
plot(iris)
1+1
knitr::include_graphics("test-3.png")
```
# Placing on top
```{r, fig.cap = "This is a caption", out.width = "33%", fig.show = "hold", fig.topcaption = TRUE}
knitr::include_graphics("test-1.png")
knitr::include_graphics("test-2.png")
knitr::include_graphics("test-3.png")
```
```{r, fig.cap = "This is another caption", out.width = "33%", fig.show = "hold", fig.topcaption = TRUE}
knitr::include_graphics(c("test-1.png", "test-2.png", "test-3.png"))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment