Takes a ggplot2 object and formats it as a 23.16cm x 23.16cm square image suitable for social media. The layout consists of a grey title bar containing the title and logo, a subtitle area, a chart panel, and a caption area.

create_blog(
  plot = ggplot2::last_plot(),
  font = c("slide", "normal"),
  ignore_long_title = FALSE
)

Arguments

plot

A ggplot2 plot.

font

Either "slide" (default) or "normal". "slide" uses DM Serif Display for the title and Avenir Next for body text (if available). "normal" uses the default sans-serif font.

ignore_long_title

Default is FALSE. If TRUE, the check on a long title won't be performed. This is useful if using ggtext syntax within titles.

Value

An object of class "patchwork" sized for a 23.16cm x 23.16cm blog image.

Details

You will rarely need to call this function directly - use `grattan_save()` with `type = "blog"` (or `grattan_save_web()`) to save a ggplot2 object as a blog image.

Examples

library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) +
    geom_point() +
    labs(title = "My title",
         subtitle = "My subtitle",
         caption = "My caption") +
    theme_grattan()

p_blog <- create_blog(p, font = "normal")