wrap_labs.Rd
Use `wrap_labs()` to wrap the title, subtitle, and caption of a ggplot2 chart onto multiple lines, left-align them, and split 'notes' and 'source' onto multiple lines. Note that this is done automatically for you if you use `grattan_save()` - there is no need to use `wrap_labs()` if you also plan to use `grattan_save()`.
wrap_labs(
object,
type,
labs_to_wrap = c("title", "subtitle", "caption"),
ignore_long_title = TRUE
)
Name of the ggplot2 chart object with the labels you wish to modify.
The type of chart you intend to save (different chart types have
different numbers of characters on each line). `type` can be 'normal',
'fullslide', 'blog', etc. For a full list of possible types, see
?grattan_save()
.
Default is c("title", "subtitle", "caption"), which wraps all three labels. Choose one or two if you only want to wrap those.
Default is FALSE. If TRUE, the check on a long title won't be performed. This is useful if using ggtext syntax within titles.
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
theme_grattan() +
labs(title = "My title goes here and is quite long and needs to break
over two lines, as is common for Grattan charts",
subtitle = "Subtitle goes here",
caption = "Notes: Put some notes here. Source: Put your source here.")
p_wrapped <- wrap_labs(p, "normal")
p_wrapped