5.12 Time: Slope charts
5.12.1 Data & Packages & functions
- Figure 5.21 and 5.22 depict slope graphs (and the first lines of the underlying data) that can be plotted relatively easily.
- What does the graph show? What are the underlying variables (and data)?
- How many scales/mappings does it use? Could we reduce them?
- What do you like, what do you dislike about the figure? What is good, what is bad?
- What kind of information could we add to the graph (if any)?
- How would you approach a replication of the graph?
5.12.3 Lab: Data & Code
head(newgdp) custom_colors <- tidyr::pivot_wider(newgdp, id_cols = Country, names_from = Year, values_from = GDP) %>% mutate(difference = Year1979 - Year1970) %>% mutate(trend = case_when( difference >= 2 ~ "green", difference <= -1 ~ "red", TRUE ~ "gray" ) ) %>% select(Country, trend) %>% tibble::deframe() newggslopegraph(newgdp, Year, GDP, Country, Title = "Gross GDP", SubTitle = NULL, Caption = NULL, LineThickness = .5, YTextSize = 4, LineColor = custom_colors )