| Title: | AAGI Branding for Graphical and Tabular Outputs |
|---|---|
| Description: | Applies Analytics for the Australian Grains Industry ('AAGI') external brand guidelines to graphics. 'AAGI' colours and font guidelines are applied as useful and reasonable to base graphics, 'ggplot2' figures, 'flextable' and 'gt' objects. |
| Authors: | Adam H. Sparks [aut, cre] (ORCID: <https://orcid.org/0000-0002-0061-8359>), Kenyon Ng [aut] (ORCID: <https://orcid.org/0000-0002-6315-9831>), Jimmy Ng [ctb], Tinula Kariyawasam [aut], Matt Cowgill [aut] (Wrote portions of package used in creating this one for 'Grattan' package, adapted to 'AAGIThemes' under 'MIT' licence.), Will Mackey [aut] (Wrote portions of package used in creating this one for 'Grattan' package, adapted to 'AAGIThemes' under 'MIT' licence.), Grains Research and Development Corporation [fnd, cph] (GRDC Project CUR2210-005OPX (AAGI-CU), ROR: <https://ror.org/02xwr1996>) |
| Maintainer: | Adam H. Sparks <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 2.1.1 |
| Built: | 2026-05-26 06:28:57 UTC |
| Source: | https://github.com/AAGI-AUS/AAGIThemes |
Insert the AAGI logo in any graphical image. Particularly well- suited for use with files created with AAGIThemes. The logo will be inserted in the upper-left of the image with a size of at least 4.6 cm as per AAGI brand guidelines.
add_aagi_logo(file_in, file_out, logo_width = 4.6, overwrite = FALSE)add_aagi_logo(file_in, file_out, logo_width = 4.6, overwrite = FALSE)
file_in |
Path to the graphical file to import and add the AAGI logo to apply the logo to. |
file_out |
File name to create on disk as a .png format image. |
logo_width |
Size for the logo in centimetres. Defaults to 4.6 cm, the smallest allowed by the AAGI guidelines. Larger sizes may be beneficial for larger graphical images than normal reporting and sharing. |
overwrite |
A Boolean value that indicates whether to overwrite an
existing file or not. Defaults to |
An invisible NULL, called for its side effect of adding the
AAGI logo to the plot that's called.
This function checks the image's DPI values and sets the logo size accordingly. When saving, e.g., from ggplot, specify the DPI value along with your height and width and units for optimal performance. 'ggsave( filename = "AAGI.png", plot = p1, path = tempdir(), width = 18, height = 18, units = "cm", dpi = 300 )
Adam Sparks, [email protected]
library("ggplot2") p1 <- ggplot(mtcars) + geom_point(aes( x = wt, y = mpg, colour = factor(gear) )) + facet_wrap(~am) + theme_aagi() ggsave(p1, filename = "AAGI.png", path = tempdir()) add_aagi_logo( file_in = file.path(tempdir(), "AAGI.png"), file_out = file.path(tempdir(), "AAGI_logo.png") ) x <- magick::image_read(file.path(tempdir(), "AAGI_logo.png")) print(x)library("ggplot2") p1 <- ggplot(mtcars) + geom_point(aes( x = wt, y = mpg, colour = factor(gear) )) + facet_wrap(~am) + theme_aagi() ggsave(p1, filename = "AAGI.png", path = tempdir()) add_aagi_logo( file_in = file.path(tempdir(), "AAGI.png"), file_out = file.path(tempdir(), "AAGI_logo.png") ) x <- magick::image_read(file.path(tempdir(), "AAGI_logo.png")) print(x)
Basic barplots that follow a standard AAGI style
including typography guidelines that uses (hopefully) sensible defaults.
All valid barplot() options are supported through ..., for e.g.,
col to set the colour. Defaults to "AAGI Black", a very dark grey
colour.
barplot_aagi(height, ...)barplot_aagi(height, ...)
height |
Either a vector or matrix of values describing the bars which
make up the plot. If height is a vector, the plot consists of a sequence
of rectangular bars with heights given by the values in the vector. If
height is a matrix and beside is |
... |
Arguments to be passed to methods, such as graphical parameters
(see |
A barplot object, returned invisibly (see graphics::barplot()).
Adam Sparks, [email protected]
graphics::plot() for full documentation of the basic plotting
capabilities.
plot_aagi, boxplot_aagi, hist_aagi
Other Baseplots:
boxplot_aagi(),
hist_aagi(),
plot_aagi()
barplot_aagi(islands) barplot_aagi(islands, col = "AAGI Orange")barplot_aagi(islands) barplot_aagi(islands, col = "AAGI Orange")
Basic boxplots that follow a standard AAGI style
including typography guidelines that uses (hopefully) sensible defaults.
All valid boxplot() options are supported through ..., for e.g.,
col to set the colour. Defaults to "AAGI Black", a very dark grey
colour.
boxplot_aagi(x, main = "", sub = "", xlab = "", ylab = "", pch = 16, ...)boxplot_aagi(x, main = "", sub = "", xlab = "", ylab = "", pch = 16, ...)
x |
for specifying data from which the boxplots are to be produced.
Either a numeric vector, or a single list containing such vectors.
Additional unnamed arguments specify further data as separate vectors (each
corresponding to a component boxplot). |
main |
Main title. Optional, if not supplied it will be blank. |
sub |
Sub title below x-axis label. Optional, if not supplied it will be blank. |
xlab |
X-axis label. Optional. |
ylab |
Y-axis label. Optional. |
pch |
plotting 'character', i.e., symbol to use. |
... |
Arguments to be passed to methods, such as graphical parameters
(see |
A boxplot object, returned invisibly (see graphics::boxplot()).
Adam Sparks, [email protected]
graphics::boxplot() for full documentation of the basic boxplot
capabilities, and
graphics::par() for full documentation of pch.
graphics::boxplot() for full documentation of the basic plotting
capabilities.
barplot_aagi, hist_aagi, plot_aagi
Other Baseplots:
barplot_aagi(),
hist_aagi(),
plot_aagi()
boxplot_aagi(decrease ~ treatment, data = OrchardSprays, xlab = "treatment", ylab = "decrease" )boxplot_aagi(decrease ~ treatment, data = OrchardSprays, xlab = "treatment", ylab = "decrease" )
Basic histograms that follow a standard AAGI style
including typography guidelines that uses (hopefully) sensible defaults.
All valid hist() options are supported through ..., for e.g.,
col to set the colour. Defaults to "AAGI Black", a very dark grey colour.
hist_aagi( x, main = "", sub = "", xlab = "", ylab = "Count", breaks = "scott", ... )hist_aagi( x, main = "", sub = "", xlab = "", ylab = "Count", breaks = "scott", ... )
x |
A vector of values for which the histogram is desired. |
main |
Main title. Optional, if not supplied it will be blank. |
sub |
Sub title below x-axis label. Optional, if not supplied it will be blank. |
xlab |
X-axis label. Optional, if not supplied will be an empty string. |
ylab |
Y-axis label. Optional, if not supplied will default to "Count". |
breaks |
One of "scott" (default), "fd", "sturges" (R's default), or "exact" (fixed bin width of 1 for integer. counts). |
... |
Arguments to be passed to methods, such as graphical parameters
(see |
A histogram object, returned invisibly (see graphics::hist()).
Adam Sparks, [email protected]
Scott, D.W. (1979) On optimal and data-based histograms. Biometrika, 66, 605–610.
Hyndman, R.J., The Problem with Sturges' Rule for Constructing Histograms, 1995, Monash University, https://www.robjhyndman.com/papers/sturges.pdf.
graphics::hist() for full documentation of the basic histogram capabilities.
barplot_aagi, boxplot_aagi, plot_aagi
Other Baseplots:
barplot_aagi(),
boxplot_aagi(),
plot_aagi()
hist_aagi(islands)hist_aagi(islands)
Basic plot that follow a standard AAGI style
including typography guidelines that uses (hopefully) sensible defaults.
All valid plot() options are supported through ..., for e.g.,
col to set the colour. Defaults to "AAGI Black", a very dark grey
colour.
plot_aagi(x, y = NULL, ...)plot_aagi(x, y = NULL, ...)
x |
the coordinates of points in the plot. Alternatively, a single plotting structure, function or any R object with a plot method can be provided. |
y |
The y coordinates of points in the plot, optional. If |
... |
Arguments to be passed to methods, such as graphical parameters
(see |
A plot object, returned invisibly (see graphics::plot()).
Adam Sparks, [email protected]
graphics::plot() for full documentation of the basic plotting
capabilities.
barplot_aagi, boxplot_aagi, hist_aagi
Other Baseplots:
barplot_aagi(),
boxplot_aagi(),
hist_aagi()
library(datasets) plot_aagi(airquality$Ozone, main = "Air Quality", xlab = "Ozone" ) plot_aagi(pressure)library(datasets) plot_aagi(airquality$Ozone, main = "Air Quality", xlab = "Ozone" ) plot_aagi(pressure)
Helpers for applying AAGI colour palettes to ggplot2 colour and fill aesthetics.
scale_colour_aagi( palette = NULL, discrete = TRUE, colours = NULL, values = NULL, ... ) scale_fill_aagi( palette = NULL, discrete = TRUE, colours = NULL, values = NULL, ... )scale_colour_aagi( palette = NULL, discrete = TRUE, colours = NULL, values = NULL, ... ) scale_fill_aagi( palette = NULL, discrete = TRUE, colours = NULL, values = NULL, ... )
palette |
Character name of a palette supported by
|
discrete |
Logical; should the scale be discrete? Defaults to |
colours |
Character vector of official AAGI colour names to
interpolate for continuous scales. If |
values |
Optional character vector of colour values to use for discrete
scales. This can be a vector of hex colours or values returned by
|
... |
Additional arguments passed to the underlying ggplot2 scale functions. |
By default, discrete scales use the official colours in
AAGIPalettes::aagi_colours. If palette is supplied, discrete scales use a
named palette from AAGIPalettes::aagi_palettes().
Continuous scales use interpolated colours via
AAGIPalettes::interpolate_aagi_colours().
scale_colour_aagi(): For colour scales
scale_fill_aagi(): For fill scales
theme_aagi(showtext_auto = TRUE) enables showtext::showtext_auto(), which
affects subsequent plots globally. Call this function to turn it off.
showtext_aagi_off()showtext_aagi_off()
Invisibly returns NULL.
This theme follows a standard AAGI style including typography guidelines that uses (hopefully) sensible defaults for ggplot2 graphics.
theme_aagi( base_size = 12, major_grid = FALSE, minor_grid = FALSE, border = FALSE, showtext_auto = TRUE, ... )theme_aagi( base_size = 12, major_grid = FALSE, minor_grid = FALSE, border = FALSE, showtext_auto = TRUE, ... )
base_size |
|
major_grid |
|
minor_grid |
|
border |
|
showtext_auto |
Important: To undo, call |
... |
Other arguments as passed along to |
Adam Sparks, [email protected]
library("ggplot2") p <- ggplot(mtcars) + geom_point(aes(wt, mpg)) + theme_aagi(showtext_auto = TRUE) p # Disable global showtext auto afterwards (recommended) showtext_aagi_off()library("ggplot2") p <- ggplot(mtcars) + geom_point(aes(wt, mpg)) + theme_aagi(showtext_auto = TRUE) p # Disable global showtext auto afterwards (recommended) showtext_aagi_off()
Apply theme AAGI to a flextable. An AAGI formatted table body is grey with a teal header and white header font. Header text is bold, text columns are left aligned, other columns are right aligned.
theme_ft_aagi(x)theme_ft_aagi(x)
x |
a flextable object |
a formatted flextable object
Theme functions are not like ggplot2 themes. They are applied to the existing table immediately. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called.
That is why theme functions should be applied after all elements of the table have been added (mainly additional header or footer rows).
If you want to automatically apply a theme function to each
flextable object, you can use the theme_fun argument of
flextable::set_flextable_defaults; be aware that this theme function is
applied as the last instruction when calling flextable::flextable() – so
if you add headers or footers to the array, they will not be formatted with
the theme.
You can also use the post_process_html argument of
flextable::set_flextable_defaults (or post_process_pdf,
post_process_docx, post_process_pptx) to specify a theme to be applied
systematically before the flextable::flextable is printed; in this
case, don't forget to take care that the theme doesn't override any
formatting done before the print statement.
Adam H. Sparks, [email protected]
Other tables:
theme_gt_aagi()
library(flextable) library(dplyr) ft <- flextable(head(airquality) |> mutate(`Month Name` = "May")) ft <- theme_ft_aagi(ft) ftlibrary(flextable) library(dplyr) ft <- flextable(head(airquality) |> mutate(`Month Name` = "May")) ft <- theme_ft_aagi(ft) ft
Apply the AAGI theme to a gt. An AAGI formatted table body is grey with a teal header and white header font. Header text is bold, text columns are left aligned, other columns are right aligned.
theme_gt_aagi(x)theme_gt_aagi(x)
x |
a gt object |
a formatted gt object
Adam H. Sparks, [email protected]
Other tables:
theme_ft_aagi()
library(gt) library(dplyr) gt <- head(airquality) |> mutate(`Month Name` = "May") |> gt() gt <- theme_gt_aagi(gt) gtlibrary(gt) library(dplyr) gt <- head(airquality) |> mutate(`Month Name` = "May") |> gt() gt <- theme_gt_aagi(gt) gt
Add a Watermark Annotation Layer to a ggplot2 Object
watermark( watermark, fontsize = 120, colour = "grey90", alpha = 0.1, fontface = "bold", angle = 22 )watermark( watermark, fontsize = 120, colour = "grey90", alpha = 0.1, fontface = "bold", angle = 22 )
watermark |
String to be added as watermark |
fontsize |
Font size |
colour |
Font colour |
alpha |
Alpha (transparency; lower number = more transparent) |
fontface |
Font face ("bold" by default) |
angle |
Angle of the watermark |
A ggplot2 object with a watermark added to the plot that's called.
Adam H. Sparks, [email protected] based on Matt Cowgill's and Will Mackey's work.
library(ggplot2) # First, start with a plot: p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + theme_aagi() # Then add a watermark: p + watermark("DRAFT")library(ggplot2) # First, start with a plot: p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + theme_aagi() # Then add a watermark: p + watermark("DRAFT")