-
Notifications
You must be signed in to change notification settings - Fork 0
/
tornados.R
75 lines (64 loc) · 2.38 KB
/
tornados.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
pacman::p_load(tidyverse,
ggmap,
showtext,
htmltools)
showtext_auto()
showtext_opts(dpi = 300)
tornados <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-05-16/tornados.csv') |>
drop_na()
tor_mag_5 <- tornados |>
filter(mag == 5) |>
mutate(post = case_when(
yr >= 2000 ~ "Post-2000",
yr < 2000 ~ "Pre-2000"
))
bbox <- c(bottom = 25.75, top = 49 , right = -67, left = -125)
usmap <- get_stamenmap(bbox = bbox, zoom = 6, maptype = 'toner-lines')
font_add(
family = "fb", regular = "C:/Users/Bradf/AppData/Local/Microsoft/Windows/Fonts/Font Awesome 6 Brands-Regular-400.otf"
)
font_add_google(name = "Roboto Slab", family = "Roboto Slab")
font_add_google(name = "Roboto", family = "Roboto")
font_1 <- "Roboto Slab"
caption <- paste0("<span style='font-family:fb;'></span>",
"<span style='font-family:sans;color:#FFFFFF;'>.</span>",
"<span style='font-family:Roboto;'>bradfordjohnson | TidyTuesday - 2023 Week 20</span>")
ggmap(usmap) +
geom_segment(
data = tornados,
aes(
x = slon,
y = slat,
xend = elon,
yend = elat,
# alpha = mag,
colour = factor(mag)
)
) +
theme_void() +
scale_colour_manual(
values = c(
"#FFF5DC",
"#F6E3BB",
"#E8C584",
"#DDAD58",
"#90651C",
"#382301"
)
) +
labs(colour = "Magnitude (Fujita Scale)",
title = "Linear paths of Tornados in the US",
subtitle = "1950-2022",
caption = caption) +
theme(
plot.caption = ggtext::element_textbox_simple(margin = margin(3, 0, 0, 0, "mm"),
halign = 0, color = "gray10", size = 5),
plot.title = element_text(family = font_1, size = 12, hjust = .5, margin = margin(0,0,2,0,"mm")),
plot.subtitle = element_text(family = font_1, size = 10, hjust = .5, margin = margin(0,0,2,0,"mm")),
legend.title = element_text(family = font_1, size = 8, margin = margin(0,2,0,2,"mm")),
legend.text = element_text(family = font_1, size = 8),
plot.margin = unit(c(2,2,2,2), "mm"),
plot.background = element_rect(fill = "white", colour = "white"),
panel.background = element_rect(fill = "white", colour = "white")
)
ggsave("tornados.png")