I am trying to achieve different heights and widths for subfigures in Rmarkdown. I was hoping that just providing fig.height
and fig.width
with a vector each would work, as this does seem to work for out.height
and out.width
---
title: "Untitled"
output: pdf_document
header-includes:
- \usepackage{subfig}
---
```{r, echo = FALSE, fig.height = c(1,2,3), fig.width=c(1,1,1), fig.cap='Caption', fig.subcap=c('Subcaption 1', 'Subcaption 2', 'Subcaption 3')}
library(ggplot2)
df <- data.frame(
x = rnorm(30),
y = rnorm(30)
)
p1 <- p2 <- p3 <- ggplot(df, aes(x, y)) +
geom_point()
print(p1)
print(p2)
print(p3)
```
However, the result is this
So, it seems that all subfigures use the values fig.height = 3, fig.width= 1
Does somebody know how to specify those value for each subfigure separately?