How can i add a reasonable figure label (also known, i believe, as figure caption) in ggplot2? By figure label, i am referring to labelling a figure as "Figure 1" or "Figure 2", etc. This is useful if you are writing a paper, or even a book, and your narrative makes references to different figures whose plots you have included (in the paper or book).
Suppose i have the following R code:
library(ggplot2) library(gapminder) data(gapminder, package = 'gapminder') ggplot(subset(gapminder, year %in% 1977), aes(gdpPercap, lifeExp)) + geom_point() + ggtitle("test title") + theme(plot.title = element_text(hjust = 0.5))
What modification to the code do i need to do to add the figure label so that the figure is labelled as either "Figure 1" or "Figure 2"? "test title" in the code I have given is the (dummy) title of the plot.
I think the figure label should be placed just below the plot (below the x axis label of the plot). Just after the figure label (say "Figure 1"), I should also have the option of writing a brief note describing the salient features of the plot. For example, "Figure 1 This is a test note".