From ab00d6699b55ee224e7d09eb519fb9156f0a2720 Mon Sep 17 00:00:00 2001 From: dlcastro Date: Thu, 1 Jul 2021 20:57:08 +0300 Subject: [PATCH 1/3] Controlador de tamanho do source --- R/finalise_plot.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/finalise_plot.R b/R/finalise_plot.R index fc813a3..e85fa6f 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, souce_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) @@ -51,12 +51,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")) From 09164ac46438777f5e4926480d443c003d781f36 Mon Sep 17 00:00:00 2001 From: dlcastro Date: Thu, 1 Jul 2021 21:03:00 +0300 Subject: [PATCH 2/3] =?UTF-8?q?Corre=C3=A7=C3=A3o=20nome=20source=5Fsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/finalise_plot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/finalise_plot.R b/R/finalise_plot.R index e85fa6f..8783aaf 100644 --- a/R/finalise_plot.R +++ b/R/finalise_plot.R @@ -15,7 +15,7 @@ left_align <- function(plot_name, pieces){ return(grob) } -create_footer <- function (source_name, logo_image_path, souce_size) { +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, From a332904e54714fdcac9617ee2ea790602faf6661 Mon Sep 17 00:00:00 2001 From: dlcastro Date: Thu, 1 Jul 2021 21:13:39 +0300 Subject: [PATCH 3/3] Update finalise_plot.R --- R/finalise_plot.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/finalise_plot.R b/R/finalise_plot.R index 8783aaf..cb5f202 100644 --- a/R/finalise_plot.R +++ b/R/finalise_plot.R @@ -31,6 +31,7 @@ create_footer <- function (source_name, logo_image_path, source_size) { #' 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