initial commit
This commit is contained in:
49
scripts/make_title_globe.R
Normal file
49
scripts/make_title_globe.R
Normal file
@@ -0,0 +1,49 @@
|
||||
# scripts/make_title_globe.R
|
||||
library(ggplot2)
|
||||
library(sf)
|
||||
library(dplyr)
|
||||
library(maps)
|
||||
|
||||
# 1. Setup Data
|
||||
states_sf <- sf::st_as_sf(maps::map("state", plot = FALSE, fill = TRUE))
|
||||
|
||||
# 2. Colors
|
||||
wa_color <- "#D95F0E"
|
||||
ga_color <- "#00A88F"
|
||||
bg_fill <- "#f0f0f0"
|
||||
borders <- "#ffffff"
|
||||
ocean_col <- "#ffffff"
|
||||
|
||||
# 3. Create the Plot
|
||||
p <- ggplot() +
|
||||
# Graticules
|
||||
geom_sf(data = sf::st_graticule(lat = seq(-90, 90, 10), lon = seq(-180, 180, 10)),
|
||||
color = "#e0e0e0", linewidth = 0.1) +
|
||||
|
||||
# Background States
|
||||
geom_sf(data = states_sf,
|
||||
fill = bg_fill, color = borders, linewidth = 0.3) +
|
||||
|
||||
# Highlights
|
||||
geom_sf(data = states_sf %>% filter(ID == "washington"),
|
||||
fill = wa_color, color = borders, linewidth = 0.3) +
|
||||
geom_sf(data = states_sf %>% filter(ID == "georgia"),
|
||||
fill = ga_color, color = borders, linewidth = 0.3) +
|
||||
|
||||
# --- THE FIX ---
|
||||
# -102 was Center. -72 was too far Left.
|
||||
# -87 is the magic number (15 degrees East).
|
||||
coord_sf(crs = "+proj=ortho +lat_0=40 +lon_0=-102") +
|
||||
|
||||
# Theme
|
||||
theme_void() +
|
||||
theme(
|
||||
panel.background = element_rect(fill = ocean_col, color = NA),
|
||||
plot.background = element_rect(fill = ocean_col, color = NA)
|
||||
)
|
||||
|
||||
# 4. Save
|
||||
if(!dir.exists("assets")) dir.create("assets")
|
||||
ggsave("assets/study_sites_globe.png", plot = p, width = 10, height = 10, dpi = 300)
|
||||
|
||||
message("Success! Globe rotated 15 degrees.")
|
||||
Reference in New Issue
Block a user