#' @title Plot functions for RSFIA package
#' @description
#'
#' Multiple functions for plotting. Some generate data.
#'
#' @name RSFIA_plots
NULL
#' @describeIn RSFIA_plots Plots by-section mortality vs. MAT
#' @export
PlotTenYearMAT <- function(source = 'mort_rate') {
mort <- FIA_mortality_with_explanatory
mort_cols0 <- c('mort_rate', 'non_harv_fire_beet_mort_rate',
'Fire_rate_wrt_ntree', 'Insect_rate_wrt_ntree')
mort_cols <- c('LAT', 'LON', 'Cleland_province', 'Cleland_section', mort_cols0)
mort <- mort[, which(colnames(mort) %in% mort_cols)]
colnames(mort)[which(colnames(mort) == source)] <- 'mortality'
wth_10 <- FIA_weather_by_year_bin
wth_10 <- wth_10[, c(1, 2, grep(colnames(wth_10), pattern = '10'))]
data <- dplyr::left_join(mort, wth_10, by = c('LAT', 'LON'))
data$Cleland_section <- RSFIA::KeyClelandCode(data$Cleland_section, lvl = 'section')
ytag <- switch(which(mort_cols0 == source),
'10-Year Mean Mortality',
'10-Year Non-Harvest/Fire/Insect Mortality',
'10-Year Fire Mortality',
'10-Year Insect Mortality')
plot_list <- list()
cnt <- 0
for (i in unique(data$Cleland_section)) {
cnt <- cnt + 1
xtag <- paste0('10-Year MAT, ', i)
i_data <- data[which(data$Cleland_section == i), ]
i_plot <- ggplot() + theme_bw() +
geom_point(aes(x = mean_max_min_10, y = mortality), data = i_data) +
ylab(ytag) + xlab(xtag)
plot_list[[cnt]] <- i_plot
}
return(plot_list)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.