View source: R/tiktok_preview.R
tiktok_preview | R Documentation |
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.
tiktok_preview(plot)
plot |
a ggplot object, fully styled and ready to go. |
(Invisibly) the pathname of the generated png.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.