#' Takes an existing ggplot object and adds site metadata as a title
#' @export
#' @title Add site metadata to ggplot
#' @param plot a ggplot object.
#' @param site 6-character site code (e.g. 'US-NR1').
#' @param db 3-character database code (e.g. 'FLX').
#' @param longname full site name/description.
#' @param country country of origin for site.
#' @param lat latitude.
#' @param long longitude.
#' @param MAT mean annual temperature (°C).
#' @param MAP mean annual precipitation (mm).
#' @param IGBP International Geosphere–Biosphere Programme land classification code (forests ONLY).
fAddSiteMeta2Plot <- function(plot, site, db, longname, country, lat, long, MAT, MAP, IGBP) {
# Adding some test code to demonstrate how changes are made
x <- 300
plot_final <- plot + ggplot2::ggtitle(paste0(site, ", ", db, " (", longname, ")"),
subtitle = paste0("Country: ", country,
" lat: ", round(lat, 2),
"; long: ", round(long,2),
" MAT: ", round(MAT, 1),"\u00B0C; MAP: ", round(MAP,0), "mm",
" Forest type: ", IGBP)) +
ggplot2::theme(plot.title = ggplot2::element_text(color="black", hjust = 0.5, size=14, face="bold"),
plot.subtitle = ggplot2::element_text(color="black", hjust = 0.5, size=12))
return(plot_final)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.