Function returning multiple plots inside Rmarkdown plots printed side by side instead one above the other

Viewed 278

I created a function to generate multiple graphs, as a helper function. The problem is that when I knit the document those graphs stay side by side and I intended for them to be one above the other using a function.

Example:

---
title: "R Notebook"
output:
pdf_document: default
---

mult_plot <- function(x) {
    plot(x)
    barplot(x)
    hist(x)
}

x <- 1:10

mult_plot(x)
```

I would like to use a function because I have a lot of plots and a lot of variables to plot and I prefer not to copy and paste individual code for each one of them. Any help appreciated.

1 Answers

To stack plots vertically, you can try adding fig.align='center' to your chunk options.

Related