scripts/06_plot_obs_R0.R

# plot R0 vs mean annual day and night temperatures


devtools::load_all()

library(ggplot2)


# define parameters -----------------------------------------------------------


response <- "R0_1"

covariates <- c("DayTemp_const_term", "NightTemp_const_term")

dir_save <- file.path("figures", "trait_R0_relationships")


# load data -------------------------------------------------------------------


foi_covariates <- readRDS(file.path("output", "foi_data_cov_rescaled.rds"))


# make plots ------------------------------------------------------------------


for (i in seq_along(covariates)) {

  covar <- covariates[i]

  out_file_name <- paste0(response, "_", covar)

  p <- preds_vs_obs_scatter_plot_2(df = foi_covariates, x = covar, y = response, add = "loess")

  save_plot(p, dir_save, out_file_name, wdt = 8, hgt = 8)

}

# histogram

p <- ggplot(data = foi_covariates, mapping = aes_string(x = response)) +
  geom_histogram(col = "white", bins = 40) +
  scale_x_continuous("Observed R0 value", breaks = seq(0,13,1)) +
  scale_y_continuous("Frequency") +
  coord_cartesian(xlim = c(0, 13)) +
  ggtitle("Distribution of the data") +
  theme_classic()

save_plot(p, "figures", "hist_observed_R0", wdt = 9, hgt = 8)
lorecatta/DENVclimate documentation built on Dec. 11, 2019, 7:05 a.m.