This vignette shows how to generate seasonal plots of LFMC values.
library(LFMC) library(tidyverse) # data transforming and plotting library(ggplotFL) # drawing quantiles library(viridis) # color scales for plots
setDBpath("../data/lfmc.sqlite")
spCodes <- c(1, 2) # Salvia rosmarinus and Quercus coccifera siteCodes <- c(7, 8)
for(sp in spCodes) { for(site in siteCodes) { p <- seasonalPlot(speciesCode = sp, siteCode = site, period = "Fortnight", MOutliers = T, AOutliers = F, plotCurrentYear = T) # Plot style p <- p + theme_light() # Axis x - Fortnightly data p <- p + scale_x_continuous(breaks = seq(0.7, 26, 2.2), labels = c("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec")) # Defining the limits of the y-axis by species if(sp == 1) { p <- p + scale_y_continuous(limits = c(30, 190), breaks = seq(30, 190, 40)) } else if(sp == 2) { p <- p + scale_y_continuous(limits = c(55, 160), breaks = seq(55, 160, 20)) } # Axis size p <- p + theme(axis.text.x = element_text(size = 7, vjust = 0.9)) p <- p + theme(axis.text.y = element_text(size = 7)) # Axis titles p <- p + labs(x = "", y = "") p <- p + theme(axis.title.y = element_text(size = 8)) # Plot title spName <- p$data[["SpeciesName"]][[1]] siteName <- p$data[["SamplingSiteName"]][[1]] p <- p + ggtitle(paste(spName, siteName, sep = " - ")) p <- p + theme(plot.title = element_text(size = 8, hjust = 0.5, color= "gray30")) # Legend p <- p + theme(legend.position = "bottom", legend.box.spacing = unit(-0.4, 'cm')) p <- p + theme(legend.title = element_text(size = 8, color= "gray30")) p <- p + theme(legend.text = element_text(size = 8, color= "gray30")) print(p) } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.