Skip to content

Commit

Permalink
Merge pull request #235 from wdwatkins/master
Browse files Browse the repository at this point in the history
change some colors on plots
  • Loading branch information
wdwatkins authored Aug 23, 2019
2 parents 96f1b97 + 45a1500 commit be017db
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/visualize/state_traffic_population.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ visualize.app_state_pop_vs_traffic <- function(viz){
}

state_traffic_pop_bars <- function(app_state_traffic) {
bars <- ggplot(app_state_traffic, aes(x = reorder(abbr, pct_traffic_divby_pop), y= pct_traffic_divby_pop, fill = pop_pct)) +
bars <- ggplot(app_state_traffic, aes(x = reorder(abbr, pct_traffic_divby_pop),
y= pct_traffic_divby_pop, fill = pop_pct)) +
geom_col() + coord_flip() +
labs(x = "State", y = "Percent of traffic divided by percent of population", fill = "Percent of U.S. population") +
geom_hline(yintercept = 1) +
scale_fill_gradient(low = "white", high = "black")
geom_hline(yintercept = 1, col = "blue") +
scale_fill_gradient(low = "white", high = "black") +
scale_y_continuous(limits = c(0, NA))
return(bars)
}

state_traffic_pop_map <- function(app_state_traffic) {
map <- plot_usmap(regions = "states", data = app_state_traffic,
values = "pct_traffic_divby_pop") +
scale_fill_gradient2(name = "% traffic over\n % population") +
values = "pct_traffic_divby_pop",
lines = "grey75") +
scale_fill_gradient2(name = "% traffic over\n % population",
low = "red", high = "blue",
midpoint = 1) +
theme(legend.position = c(0.35, 0.9), legend.direction = "horizontal",
legend.background = element_blank())
return(map)
Expand Down

0 comments on commit be017db

Please sign in to comment.