Captions for drawings with several graphs in one fragment

I draw my figures as follows.

---
title: "xxx"
output: 
  pdf_document:
    fig_caption: true
---

And then in each fragment

```{r, fig.cap="some caption"}
qplot(1:5)
```

It works very well. However, in pieces where I draw several shapes in a loop, I cannot specify a signature. This does not create any headers:

```{r, fig.cap="another caption"}
qplot(1:5)
qplot(6:10)
```

How can I specify a figure calculated from the same number as the first piece for each chart?

+4
source share
1 answer

You can use the fig.cap argument of length 2 (or the size of your loop):

```{r, fig.cap=c("another caption", "and yet an other")}
qplot(1:5)
qplot(6:10)
```
+8
source

Source: https://habr.com/ru/post/1664213/


All Articles