finalize_plot: Arrange alignment and save FiveThirtyEight ggplot chart

Description Usage Arguments Value Examples

Description

Running this function will save your plot with the guidelines similar to those used in in a FiveThirtyEight graphic. It will left align your title, subtitle and source, add the FiveThirtyEight blocks at the bottom left and save it to your specified location.

Usage

1
2
3
finalize_plot(plot_name, source_name,
  save_filepath = file.path(Sys.getenv("TMPDIR"), "tmp-nc.png"),
  width_pixels = 640, height_pixels = 450)

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 come after the text 'SOURCE:' in the bottom right hand side of your side

save_filepath

Exact 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

Value

(Invisibly) an updated ggplot object. #' @keywords finalise_plot

Examples

1
2
3
4
5
6
7
8
library(ggplot2)
hist <- ggplot(diamonds) + geom_histogram(aes(x = price))
finalize_plot(plot_name = hist,
source = "The source for my data",
save_filepath = "filename_that_my_plot_should_be_saved_to-nc.png",
width_pixels = 640,
height_pixels = 450
)

kiernann/fivethirtyplot documentation built on May 14, 2019, 11:06 p.m.