finalise_plot: Arrange alignment and save Newsworthy style ggplot chart

Description Usage Arguments Value Examples

Description

Running this function will save your plot with the correct guidelines for publication It will left align your title, subtitle, legend and source, add the Newsworthy logo at the bottom right and save it to your specified location.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
finalise_plot(
  plot_name,
  source_name = NULL,
  save_filepath = file.path(tempdir(), "tmp-nc.png"),
  width_pixels = 640,
  height_pixels = 450,
  logo_image_path = file.path(system.file("data", package = "jpplot2"),
    "newsworthy-logo.png"),
  left_aligned = c("title", "subtitle", "legend"),
  footnote = NULL,
  scale = 0.7
)

Arguments

plot_name

The variable name of the plot you have created that you want to format and save

source_name

The text you want to put including the text 'Source:' in the bottom left hand side of your side

save_filepath

Exact or relative filepath that you want the plot to be saved to

width_pixels

Width in pixels that you want to save your chart to - defaults to 640

height_pixels

Height in pixels that you want to save your chart to - defaults to 450

logo_image_path

File path for the logo image you want to use in the right hand side of your chart, which needs to be a PNG file - defaults to Newsworthy logo that sits within the data folder of your package

left_aligned

Character vector naming the left-aligned elements that you want to shift from the left of the plot area to the left of the graph. The default option covers the title, subtitle and legend.

footnote

String that you would like to appear below plot and above source and logo. Add line breaks by using newline characters (\n) - defaults to no footnote

tinify_file

Boolean that if set to TRUE will compress your png using Will's tinifyr package - defaults to FALSE

Value

(Invisibly) an updated ggplot object.

Examples

1
2
3
4
5
6
7
finalise_plot(plot_name = myplot,
source = "The source for my data",
save_filepath = "filename_that_my_plot_should_be_saved_to-nc.png",
width_pixels = 640,
height_pixels = 450,
logo_image_path = "logo_image_filepath.png"
)

cguibourg/jpplot2 documentation built on Dec. 30, 2019, 8:43 p.m.