tiktok_preview: Check whether a layout fits in tik-tok safe spaces

View source: R/tiktok_preview.R

tiktok_previewR Documentation

Check whether a layout fits in tik-tok safe spaces

Description

Takes your plot, saves it out at 1080x1920px, overlays a tiktok view of buttons etc. on top of that and then previews the resultant image.

Usage

tiktok_preview(plot)

Arguments

plot

a ggplot object, fully styled and ready to go.

Value

(Invisibly) the pathname of the generated png.

Examples


library(ggplot2)

plot <- ggplot(uk_gdp, aes(x = date, y = value)) +
  geom_line(colour = tvcols["news"], lineend = "round") +
  labs(
    title = "Quarterly UK GDP",
    caption = "Source: Office for National Statistics"
  ) +
  portrait_style(
    plot_margins = c(252, 240, 400, 80),
    bottom = 250
  ) +
  scale_y_continuous(
    label = scales::label_dollar(
      prefix = "£",
      scale_cut = c(" " = 0, "bn" = 1e3, "tn" = 1e6)
    )
  )

## Not run: 

tiktok_preview(plot)

tiktok_preview(plot + portrait_style(plot_margins = c(150, 20, 20, 20)))

## End(Not run)

bbcuffer/rcutils documentation built on Nov. 10, 2023, 12:08 p.m.