I would like to include a figure on a beamer slide produced by Rmarkdown / knitr. Setting the fig.width
or fig.height
options in the R code chunk changes the relative size of all plot elements (e.g. setting a smaller size makes fonts and geoms larger proportional to the plot area), but the plot still takes up most of the slide.
Instead, I would like to present a plot that takes up less area on the slide. How can I do that?
Note that this is a different question to this, which is asking about how to produce vector graphics. My figures are saved as pdf.
EDIT: after trying some more examples, it seems I just needed to be more extreme in my resizing and to manually adjust the base font size in the ggplot2 theme.
Sorry! My bad.
Reproducible example:
```{r logit, fig.width=1.5, fig.height=1.1}
library(ggplot2)
tmp <- data.frame(x = seq(-5, 5, length.out = 50))
tmp$y <- plogis(tmp$x)
plt <- ggplot(tmp, aes(x = x, y = y)) +
geom_line() +
xlab("Linear predictor") + ylab("Probability") +
theme_minimal(base_size = 8)
plt
```