How To Add Captions To Plot Figures R

3 min read

Learning how to add captions to plot figures in R is an essential skill for anyone working with data visualization, statistical reporting, or academic research. A well-placed caption provides context, credits data sources, explains abbreviations, or documents the analysis date without cluttering the main plotting area. Whether you are preparing a publication-quality figure for a journal or creating a quick exploratory chart in RStudio, knowing how to attach a clear, properly formatted caption ensures your visualizations communicate their message effectively and professionally Most people skip this — try not to..

You'll probably want to bookmark this section Small thing, real impact..

Why Captions Matter in R Data Visualization

Captions serve as the quiet anchor of a figure. While titles grab attention and axis labels explain variables, captions handle the fine print that makes a chart trustworthy. In R, adding captions to plot figures helps you:

  • Cite the original dataset or API source.
  • Note data transformations, such as log scaling or outlier removal.
  • Record the date the analysis was performed.
  • Define acronyms used in axis labels or legends.
  • Comply with journal or institutional formatting guidelines.

Without a caption, readers may misinterpret the data or question its origin. A strong caption adds transparency and strengthens the reproducibility of your work.

Adding Captions in Base R

Base R graphics do not have a single “caption” argument like modern plotting packages, but you can add figure captions using a few reliable functions. The most flexible approach is the mtext() function, which places text in the margins of the plot And that's really what it comes down to..

This is where a lot of people lose the thread.

Using the mtext() Function

To add a caption below a base R plot, use mtext() with the side argument set to 1 (bottom margin). Here is the basic syntax:

plot(mtcars$wt, mtcars$mpg,
     main = "Fuel Efficiency vs. Vehicle Weight",
     xlab = "Weight (1000 lbs)",
     ylab = "Miles per Gallon")

mtext("Source: 1974 Motor Trend US magazine data",
      side = 1,
      line = 3.5,
      adj = 0,
      cex = 0.8,
      col = "gray40")

Key parameters to understand:

  • side: 1 places the caption at the bottom, 2 on the left, 3 at the top, and 4 on the right.
  • line: Controls how many margin lines away from the plot region the text appears. Higher values push the caption farther outward.
  • adj: Adjusts horizontal alignment. A value of 0 left-aligns the text, 0.5 centers it, and 1 right-aligns it.
  • cex: Sets the character expansion factor, effectively controlling font size relative to the default.
  • col: Changes the text color so the caption remains visible but subordinate to the main plot.

Using the title() Function with sub

Another base R option is the sub argument inside title(). This adds a subtitle directly beneath the main title, which can function as a short caption:

plot(mtcars$wt, mtcars$mpg,
     main = "Scatterplot of mtcars",
     sub = "Data: mtcars package | Analysis date: 2024")

This method is quicker but offers less control over positioning and styling compared to mtext().

Positioning and Formatting Base R Captions

For multi-panel figures created with par(mfrow = ...), you may want an outer caption that spans the entire figure. Set outer = TRUE in mtext() and adjust oma (outer margin area) in par() to reserve space:

par(oma = c(3, 0, 0, 0))
# ... plotting
Brand New

New Stories

Along the Same Lines

We Picked These for You

Thank you for reading about How To Add Captions To Plot Figures R. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home