Running this function will save your plot with the correct guidelines for publication for a branded graphic. It will left align your title, subtitle and source, add the brand logo at the bottom right and save it to your specified location.
Usage
finalise_plot(
plot,
filepath = "",
add_footer = FALSE,
source,
font_size = 13,
width_pixels = 600,
height_pixels = 800,
logo = FALSE,
brand = c("g6tr", "populace"),
left_align = TRUE,
background_color = "white",
footer_margin = FALSE,
dpi = 300
)Arguments
- plot
The variable name of the plot you have created that you want to format and save
- filepath
Exact filepath that you want the plot to be saved to. If you don't want to save the plot, leave this blank.
Whether to add a footer with a source and logo or not.
- source
The text you want to come after the text 'Source:' in the
- font_size
the size of the font in the source bottom left hand side of your side
- width_pixels
Width in pixels that you want to save your chart to - defaults to 600
- height_pixels
Height in pixels that you want to save your chart to - defaults to 800
- logo
Adds the `brand“ logo
- brand
For what brand is the image being created? Current options are
'g6tr'and'populace'- left_align
Logical(default = TRUE). Aligns the title & subtitle to the left or not.- background_color
Color in Hex Code. Background of the entire plot. 'White' by default. Leave blank for a transparent background
Adds 10% margin to the left and right side of the footer if TRUE.
- dpi
Numeric. Default 300, however for larger (like 2000 px width) plots you might want to set this value to some higher value (e.g. 600) to avoid image blur.
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
myplot_g6tr <- ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
geom_point(size = 4) +
labs(
title = "Testing the title",
subtitle = "Testing the subtitle"
) +
theme_g6tr(type = "white") +
scale_color_g6tr(name = "")
# Gradient theme without a background color
finalise_plot(
plot = myplot_g6tr,
source = "The source for my data",
add_footer = TRUE,
logo = TRUE,
left_align = TRUE,
filepath = "source.png",
brand = "g6tr"
)
myplot_pop <- myplot_g6tr +
theme_populace(base_size = 30) +
scale_color_populace()
# populace theme with a background color
finalise_plot(
plot = myplot_pop,
source = "The source for my data",
add_footer = TRUE,
logo = TRUE,
left_align = TRUE,
filepath = "source.png",
brand = "populace",
background_color = "#D5D5D3"
)
} # }