ggplot(pop_data, aes(age, pcnt2, fill = sex)) +
geom_col(show.legend = FALSE) +
coord_flip(ylim = c(-.08, .08)) +
labs(title = "Population by Age and Gender:
{floor(frame_time/5)*5}",
x = "Age", y = "Percent of Population") +
scale_fill_manual(
values = c("hotpink3", "dodgerblue3")) +
scale_y_continuous(
breaks = seq(-.08, .08, .02),
labels = abs(seq(-8, 8, 2)) |> paste0("%")) +
annotate("text", label = "Female", size = 8,
color = "hotpink3", x = 20, y = .05) +
annotate("text", label = "Male", size = 8,
color = "dodgerblue3", x = 20, y = -.05) +
gganimate::transition_time(year)