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.
You can install {AAGIThemes} like so:
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
remotes::install_github("AAGI-AUS/AAGIThemes",
build_vignettes = TRUE,
dependencies = TRUE
)
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")
{AAGIThemes} provides a {flextable} theme suited for the AAGI style that works in HTML and Word document outputs. You can use it like so.
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
{AAGIThemes} provides a {gt} theme suited for the AAGI style that works best in HTML outputs. You can use it like so.
library(AAGIThemes)
library(dplyr)
library(gt)
gt <- head(airquality) |>
mutate(`Month Name` = "May") |>
gt()
gt <- theme_gt_aagi(gt)
gt
{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()
.
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.
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 gridlines 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()