decorate_plot: Decorate Plot Function

View source: R/decorate_plot.r

decorate_plotR Documentation

Decorate Plot Function

Description

Decorate a ggplot with title, subtitle, footer reference text and full-page background image. This makes use of the cowplot package to strip apart the basic ggplot object and recombine it into a presentation-ready image.

Usage

decorate_plot(
  plot,
  title = NULL,
  subtitle = "http://www.weirddatascience.net | @WeirdDataSci",
  footer = NULL,
  title_colour = "#3c3f4a",
  subtitle_colour = title_colour,
  footer_colour = title_colour,
  bg_colour = NULL,
  bg_image = NULL,
  decorate_theme = NULL,
  rel_heights = c(0.1, 1, 0.05)
)

Arguments

plot

ggplot plot object to centralize.

title

Title text for the plot.

subtitle

Subtitle text for the plot.

footer

Footer text, for references and acknowledgements.

title_colour

Colour for the plot title.

subtitle_colour

Colour for the plot subtitle. Defaults to the same as the title.

footer_colour

Colour for the plot footer. Defaults to the same as the title.

bg_colour

Background colour for the plot. If given, this will override the main plot's background by setting it to be transparent, and cause this colour to span the entire plot without borders. Note that this argument will override any plot.background or panel.background settings in the decorate_theme argument.

bg_image

Path to a background image for the page. This will span the entire plot without borders.

rel_heights

Array of relative heights for the title, plot, and footer sections. Defaults to c(0.1, 1, 0.05).

theme

A theme object to use in constructing the titles and footer.

Examples

df <- data.frame( x=rnorm(100), y=rnorm(100) )
gp <- ggplot( df, aes(x=x, y=y) ) + geom_point()
dp <- decorate_plot( gp, "Plot Title", "Weird Data Science", "Data: Normal Distribution" )

weirddatascience/grimoire documentation built on Oct. 26, 2024, 5:44 a.m.