Fix data and add plot.

This commit is contained in:
mattbk
2024-01-12 10:02:56 -06:00
parent b956604c30
commit a3a110fe5a
5 changed files with 189 additions and 166 deletions

View File

@ -28,6 +28,10 @@ d_total_long <- d_total %>%
values_to = "count") %>%
# only keep rows with data so plots look right
filter(!is.na(count))
d_state_total_long <- d %>% filter(State.Territory != "TOTAL") %>%
select(Date, State.Territory, Total, source_name, source_detail) %>%
filter(!is.na(Total))
#### Plots ####
@ -114,4 +118,22 @@ ggsave("plots/class-over-time.png", width = 6, height = 4)
#ggsave("plots/class-over-time-stacked.png", width = 6, height = 4)
##### By state #####
ggplot(data = d_state_total_long,
aes(x = Date,
y = Total)) +
geom_line() +
geom_point(size = 0.3) +
facet_wrap(~State.Territory,
scales = "free_y") +
scale_x_date(date_breaks = "10 years",
#date_minor_breaks = "1 year",
date_labels = "%Y") +
scale_y_continuous(labels = scales::comma) +
theme_bw() +
labs(title = "US Amateur Licenses by State",
y = "Count",
caption = "w1cdn.net") +
theme(legend.position="bottom")
ggsave("plots/states-over-time-freey.png", width = 15, height = 9)