library(ggplot2)
df <- data.frame(
x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3, y4 = (1:10)^4
)
p1 <- ggplot(df, aes(x, y1)) + geom_point()
p2 <- ggplot(df, aes(x, y2)) + geom_point()
p3 <- ggplot(df, aes(x, y3)) + geom_point()
p4 <- ggplot(df, aes(x, y4)) + geom_point()
# Create a simple grid
p <- plot_grid(p1, p2, p3, p4, align = 'hv')
# Default font size and position
p + draw_figure_label(label = "Figure 1")
# Different position and font size
p + draw_figure_label(label = "Figure 1", position = "bottom.right", size = 10)
# Using bold font face
p + draw_figure_label(label = "Figure 1", fontface = "bold")
# Making the label red and slanted
p + draw_figure_label(label = "Figure 1", angle = -45, colour = "red")
# Labeling an individual plot
ggdraw(p2) + draw_figure_label(label = "Figure 1", position = "bottom.right", size = 10)
Run the code above in your browser using DataLab