Skip to contents

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

Usage

g6tr_finalise_plot(
  plot,
  add_footer = FALSE,
  source,
  font_size = 16,
  filepath = "",
  left_align = T,
  width_pixels = 1080,
  height_pixels = 1080,
  logo = FALSE,
  type = c("grey", "white", "transparent")
)

Arguments

plot

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

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 bottom left hand side of your side

font_size

the size of the font

filepath

Exact filepath that you want the plot to be saved to. If you don't want to save the plot, leave this blank.

left_align

Should the title / subtitle be left aligned or not?

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

Add a Gradient logo if TRUE

type

The type of the plot (either grey or white). This will change the background color of the footer accordingly.

Value

(Invisibly) an updated ggplot object.

Examples

if (FALSE) { # \dontrun{
library(ggplot2)
myplot <- 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", base_size = 24) +
  scale_color_g6tr()

g6tr_finalise_plot(
  plot = myplot,
  source = "The source for my data",
  add_footer = TRUE,
  logo = TRUE,
  left_align = F,
  type = "white",
  filepath = "source.png",
  width_pixels = 600,
  height_pixels = 600
)
} # }