diff --git a/R/finalise_plot.R b/R/finalise_plot.R index fc813a3..cb5f202 100644 --- a/R/finalise_plot.R +++ b/R/finalise_plot.R @@ -15,11 +15,11 @@ left_align <- function(plot_name, pieces){ return(grob) } -create_footer <- function (source_name, logo_image_path) { +create_footer <- function (source_name, logo_image_path, source_size) { #Make the footer footer <- grid::grobTree(grid::linesGrob(x = grid::unit(c(0, 1), "npc"), y = grid::unit(1.1, "npc")), grid::textGrob(source_name, - x = 0.004, hjust = 0, gp = grid::gpar(fontsize=16)), + x = 0.004, hjust = 0, gp = grid::gpar(fontsize=source_size)), grid::rasterGrob(png::readPNG(logo_image_path), x = 0.944)) return(footer) @@ -31,6 +31,7 @@ create_footer <- function (source_name, logo_image_path) { #' It will left align your title, subtitle and source, add the BBC blocks at the bottom right and save it to your specified location. #' @param plot_name The variable name of the plot you have created that you want to format and save #' @param source_name The text you want to come after the text 'Source:' in the bottom left hand side of your side +#' @param source_size The source text size font (Default: 12) #' @param save_filepath Exact filepath that you want the plot to be saved to #' @param width_pixels Width in pixels that you want to save your chart to - defaults to 640 #' @param height_pixels Height in pixels that you want to save your chart to - defaults to 450 @@ -51,12 +52,13 @@ create_footer <- function (source_name, logo_image_path) { #' @export finalise_plot <- function(plot_name, source_name, + source_size = 12, save_filepath=file.path(Sys.getenv("TMPDIR"), "tmp-nc.png"), width_pixels=640, height_pixels=450, logo_image_path = file.path(system.file("data", package = 'bbplot'),"placeholder.png")) { - footer <- create_footer(source_name, logo_image_path) + footer <- create_footer(source_name, logo_image_path, source_size) #Draw your left-aligned grid plot_left_aligned <- left_align(plot_name, c("subtitle", "title", "caption"))