Learn R Programming

cowplot (version 0.6.3)

draw_figure_label: Add a label to a figure

Description

This function is similar to draw_plot_label, just with slightly different arguments and defaults. The main purpose of this function is to add labels specifying extra information about the figure, such as "Figure 1", which is sometimes useful.

Usage

draw_figure_label(label, position = c("top.left", "top", "top.right", "bottom.left", "bottom", "bottom.right"), size, fontface, ...)

Arguments

label
Label to be drawn
position
Position of the label, can be one of "top.left", "top", "top.right", "bottom.left", "bottom", "bottom.right". Default is "top.left"
size
(optional) Size of the label to be drawn. Default is the text size of the current theme
fontface
(optional) Font face of the label to be drawn. Default is the font face of the current theme
...
other arguments passed to draw_plot_label

Examples

Run this code

p1 <- qplot(1:10, 1:10)
p2 <- qplot(1:10, (1:10)^2)
p3 <- qplot(1:10, (1:10)^3)
p4 <- qplot(1:10, (1:10)^4)

# 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