#' Sportsfield Ggplot2 Theme
#' @param ratio The aspect ration of the plot to output
#' @examples
#' @author Robert Hickman
#' @export
theme_sportsfield <- function(ratio = 1) {
theme <- theme_void() +
theme(plot.margin = margin(0, 0 ,0 ,0))
if(ratio %in% c("soccer", "football", "baseball", "basketball", "cricket", "rugby")) {
aspect_ratio = switch(ratio,
"soccer" = 68/105,
"football" = 1,
"baseball" = 1,
"basketball" = 50/94,
"cricket" = 1,
"rugby" = 1)
theme <- theme + theme(aspect.ratio = aspect_ratio)
} else if(is.numeric(ratio) & length(ratio) == 1) {
aspect_ratio = ratio
theme <- theme + theme(aspect.ratio = aspect_ratio)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.