Skip to content

Source font size #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions R/finalise_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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"))
Expand Down