considerations

  • virtual ‘size’ of figure
  • size of figure in text
  • aspect ratio (height/width)

ways to output figures

  • “Save” button in RStudio
  • pdf(); ...; dev.off() (or the same for png(), etc.)
  • ggsave() [automatically saves most recent ggplot, but can specify a gg* object]

virtual/‘physical’ size

  • dimension arguments width, height in pdf(), png(), etc. (different units!)
    • but always inches in pdf, which is generally the best choice
  • width, height in ggsave (always inches for any format)
  • can also control text, etc. sizes with e.g. cex (base R) or theme_*(base_size = ...) (ggplot2)
  • chunk options: fig.width, fig.height (Rmarkdown), fig-width, fig-height (quarto) (can set these to a default spec in a document, in YAML header or via knitr::opts_chunk())
  • decreasing the physical size of a figure increases the relative size of text, lines, etc.
  • your axis labels are probably too small

output size

  • size on the page
  • out.height/out.width (Rmarkdown), out-height/out-width (Quarto): output-format dependent

Height of the plot in the output document, which can be different from its physical fig-height, i.e., plots can be scaled in the output document. Depending on the output format, this option can take special values. For example, for LaTeX [PDF] output, it can be 3in, or 8cm; for HTML, it can be 300px [OR “50%”]

  • Generally better to scale both dimensions the same; this will likely just work if you specify only width or height, but you should check

figuring it out