Skip to content

AAGI-AUS/AAGIThemes

Repository files navigation

Project Status: Active – The project has reached a stable, usable state and is being actively developed. R-CMD-check

{AAGIThemes} AAGI Branding for R Graphical and Tabular Outputs

This repository contains the code for the R package {AAGIThemes}, which once installed in your R session (local or RStudio Server), provides helper functions for creating and exporting graphics created in R with a unified style that follows the AAGI brand guidelines.

The goal of {AAGIThemes} is to provide easy to use theming of R graphics for AAGI team members. Following AAGI’s brand guidelines, AAGI colours are used where applicable and the font defaults to Proxima Nova. The resulting graphs, plots and charts feature a x and y axis that meet at 0 with no gridlines, but these can optionally be set to appear. The resulting maps from theme_aagi_map() feature a white canvas with the legend on the right.

Installation instructions

You can install {AAGIThemes} like so:

if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}
remotes::install_github("AAGI-Org-AU-Public/AAGIThemes",
                        build_vignettes = TRUE,
                        dependencies = TRUE
)

Quick start

Following are some quick examples of {AAGIThemes} functionality. However, you may wish to browse the vignette for a more detailed look at what the package offers using:

vignette("Cookbook", package = "AAGIThemes")

Create Tabular Outputs

{AAGIThemes} provides {flextable} and {gt} themes suited for the AAGI style that works in HTML and Word document outputs. You can use it like so with {flextable}.

library(AAGIThemes)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(flextable)
ft <- flextable(head(airquality) |>
 mutate(`Month Name` = "May"))
ft <- theme_ft_aagi(ft)
ft

Plots and graphs

{AAGIThemes} provides several functions to assist users in creating plots, charts and graphs with a more unified AAGI style.

For creating standalone graphs using R’s base library there are:

  • barplot_aagi(),

  • boxplot_aagi(),

  • hist_aagi(), and

  • plot_aagi().

Using the basic plot functions

Example of how the base graphics functionality with AAGI style pre-applied is used:

library(AAGIThemes)
boxplot_aagi(decrease ~ treatment,
              data = OrchardSprays,
              xlab = "treatment",
              ylab = "decrease")

See the respective function’s help files and the {AAGIThemes} cookbook for more examples and documentation.

Using With {ggplot2}

The function theme_aagi() is provided to apply a unified style for creating AAGI themed plots, charts and graphs using {ggplot2}. The function is very basic and provides only one parameter, base_size, which is used to set the font size (in points) used in the resulting figure. No adjustments are made by the type of graph being produced, so you may wish to add grid lines or change the colour palette that is used to alter point or line colours in your graph.

Example of how theme_aagi() is used in a standard {ggplot2} workflow:

library(AAGIThemes)
library(ggplot2)

ggplot(data = OrchardSprays, aes(x = treatment, y = decrease)) +
  geom_boxplot() +
  scale_y_continuous(breaks = seq(0, 120, by = 20)) +
  theme_aagi()

About

AAGI Branding for R Graphical and Tabular Outputs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published