How to Add Footnote to ggplot2 Plots


You can use the caption argument within the labs() function to add a footnote to a plot in ggplot2.

There are two common ways to use this argument in practice:

Method 1: Add Footnote in Bottom Right Corner

p +
  labs(caption = "Here is a footnote")

Method 2: Add Footnote in Bottom Left Corner

p +
  labs(caption = "Here is a footnote") +
  theme(plot.caption = element_text(hjust=0))

The following examples show how to use each method in practice with the following data frame in R:

#create data frame
df <- data.frame(assists=c(1, 2, 2, 3, 5, 6, 7, 8, 8),
                 points=c(3, 6, 9, 14, 20, 23, 16, 19, 26))

#view data frame
df

  assists points
1       1      3
2       2      6
3       2      9
4       3     14
5       5     20
6       6     23
7       7     16
8       8     19
9       8     26

Example 1: Add Footnote in Bottom Right Corner

The following code shows how to create a scatter plot in gglot2 and add a footnote in the bottom right corner below the plot:

library(ggplot2)

#create scatter plot with footnote in bottom right corner
ggplot(df, aes(x=assists, y=points)) +
  geom_point(size=3) +
  labs(caption = "Here is a footnote")

ggplot2 add footnote

Notice that a footnote has been added to the bottom right corner below the plot.

Example 2: Add Footnote in Bottom Left Corner

The following code shows how to create a scatter plot in gglot2 and add a footnote in the bottom left corner below the plot:

library(ggplot2)

#create scatter plot with footnote in bottom left corner
ggplot(df, aes(x=assists, y=points)) +
  geom_point(size=3) +
  labs(caption = "Here is a footnote") +
  theme(plot.caption = element_text(hjust=0))

ggplot2 add footnote in bottom left corner

Notice that a footnote has been added to the bottom left corner outside the plot.

Note that the argument hjust=0 specifies that the footnote should be left-aligned.

You can also specify hjust=0.5 to place the footnote in the bottom center outside the plot.

Related: How to Use hjust & vjust to Move Elements in ggplot2

Additional Resources

The following tutorials explain how to perform other common tasks in ggplot2:

How to Change Font Size in ggplot2
How to Remove a Legend in ggplot2
How to Rotate Axis Labels in ggplot2

Leave a Reply

Your email address will not be published. Required fields are marked *