-
Notifications
You must be signed in to change notification settings - Fork 1
Materials that have been removed, but may try to add back in
Samantha Csik edited this page Oct 30, 2024
·
1 revision
A. Install required packages
#| eval: false
#| echo: true
#| code-line-numbers: false
install.packages("geofacet") # facet data for different geographical regions using panels arranged in shapes that mimic geographic topology
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## BONUS: using {geofacet} to plot data for all states ----
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NOTE 2024-01-24: The following code works for Sam, but apparently no one else! I'll keep digging into this and update folks when I have a solution
#......remove HI & AK (no data) and also DC from preset grid.....
mygrid <- as.data.frame(geofacet::us_state_grid1) |>
filter(!code %in% c("DC", "HI", "AK"))
#..............................plot..............................
# NOTE: this takes a minute to render!
drought_clean |>
filter(drought_lvl != "None") |>
ggplot(aes(x = date, y = area_pct, fill = drought_lvl_long)) +
geom_area(position = position_stack(reverse = TRUE)) +
geofacet::facet_geo(~state_abb, grid = mygrid) +
scale_fill_manual(values = c("#853904", "#FF0000", "#FFC100", "#FFD965", "#FFFF00"))