Purpose

Create some plots to explore the 2017-2020 pesticide use data for the Sacramento River and Yolo Bypass regions.

Global code and functions

# Load packages
library(tidyverse)
library(scales)
library(here)

Import and Prepare Data

df_pest_use <- readRDS(here("manuscript_contam/data/processed/pesticide_use_daily_tot_2017-2020.rds"))
df_pest_use_c <- df_pest_use %>% 
  mutate(
    PesticideClass = factor(PesticideClass, levels = c("Rice", "Pyrethroid", "Other")),
    DOY = yday(Date),
  )

Plots

Daily totals

df_pest_use_c %>% 
  ggplot(aes(x = DOY, y = TotalApplication, fill = PesticideClass)) +
  geom_col() +
  facet_grid(rows = vars(Year), cols = vars(Region)) +
  scale_fill_viridis_d(
    name = "Pesticide Class", 
    option = "plasma", 
    end = 0.8
  ) +
  scale_y_continuous(
    name = "Total Application (lbs)",
    labels = label_comma()
  ) +
  theme_bw() +
  theme(legend.position = "top")

Monthly Totals

df_pest_use_c %>% 
  summarize(
    TotalApplication = sum(TotalApplication),
    .by = c(Region, Month, Year, PesticideClass)
  ) %>% 
  ggplot(aes(x = Month, y = TotalApplication, fill = PesticideClass)) +
  geom_col() +
  facet_grid(rows = vars(Year), cols = vars(Region)) +
  scale_fill_viridis_d(
    name = "Pesticide Class", 
    option = "plasma", 
    end = 0.8
  ) +
  scale_y_continuous(
    name = "Total Application (lbs)",
    labels = label_comma()
  ) +
  theme_bw() +
  theme(legend.position = "top")