Skip to content
Snippets Groups Projects
Commit a871a09e authored by Azadpour, Elmera's avatar Azadpour, Elmera
Browse files

update census maps leg labels

parent ba13441f
No related branches found
No related tags found
1 merge request!62Edits from Joe
......@@ -9,6 +9,7 @@ p3_targets <- list(
census_data = p2_perc_census_acs5_layers_sf[[2]],
lim_vals = c(0, 155000),
percent_leg = FALSE,
dollar_leg = TRUE,
var = 'estimate',
conus_sf = p1_conus_sf,
outfile_path = "3_visualize/out/med_income_census_2022.png",
......@@ -28,6 +29,7 @@ p3_targets <- list(
plot_census_map(
census_data = p2_perc_census_acs5_layers_sf[[4]],
percent_leg = TRUE,
dollar_leg = FALSE,
lim_vals = c(0, 100),
break_vals = c(0, 25, 50, 75, 100),
var = 'percent',
......@@ -49,6 +51,7 @@ p3_targets <- list(
plot_census_map(
census_data = p2_census_acs5sub_household_data[[1]],
percent_leg = FALSE,
dollar_leg = FALSE,
lim_vals = c(1, 5),
var = 'estimate',
conus_sf = p1_conus_sf,
......@@ -69,6 +72,7 @@ p3_targets <- list(
plot_census_map(
census_data = p2_census_acs5sub_household_data[[2]],
percent_leg = FALSE,
dollar_leg = TRUE,
lim_vals = c(0, 3000),
var = 'estimate',
conus_sf = p1_conus_sf,
......@@ -89,6 +93,7 @@ p3_targets <- list(
plot_census_map(
census_data = p2_census_acs5sub_disability_data[[1]],
percent_leg = TRUE,
dollar_leg = FALSE,
lim_vals = c(0, 50),
break_vals = c(0, 10, 20, 30, 40, 50),
var = 'estimate',
......
......@@ -9,6 +9,7 @@
#' @param width, set figure width dimension
#' @param height, set figure height dimension
#' @param percent_leg if else statement where if TRUE, apply 0-100 legend, otherwise retain 0 - max of variable name
#' @param dollar_leg if else statement where if TRUE, apply $ to the estimate column to display cost in USD on map
#' @param font_size, set font size
#' @param barheight, set colorbar bar height
#' @param barwidth, set colorbar bar width
......@@ -16,7 +17,8 @@
#' @param break_vals, set legend breaks
plot_census_map <- function(census_data, conus_sf, leg_title, outfile_path, var,
percent_leg, viz_config_df, viz_config_pal, width, height,
font_size, barwidth, barheight, lim_vals, break_vals){
font_size, barwidth, barheight, lim_vals, break_vals,
dollar_leg){
font_legend <- viz_config_df$load_font
font_add_google(font_legend)
......@@ -45,13 +47,14 @@ plot_census_map <- function(census_data, conus_sf, leg_title, outfile_path, var,
))
if (percent_leg == FALSE) {
census_map <- census_map +
scale_fill_gradientn(
colors = colorRampPalette(c("#eef0ff", viz_config_pal))(100),
name = leg_title,
limits = lim_vals,
labels = scales::comma,
na.value="#F5F5F5")
census_map <- census_map +
scale_fill_gradientn(
colors = colorRampPalette(c("#eef0ff", viz_config_pal))(100),
name = leg_title,
limits = lim_vals,
labels = if (dollar_leg) scales::label_dollar() else scales::comma,
na.value = "#F5F5F5"
)
} else {
census_map <- census_map +
......@@ -60,9 +63,11 @@ plot_census_map <- function(census_data, conus_sf, leg_title, outfile_path, var,
name = leg_title,
limits = lim_vals, # c(0, 100),
breaks = break_vals, # c(0, 25, 50, 75, 100),
labels = if (dollar_leg) scales::label_dollar() else function(x) paste0(x, "%"),
na.value="#F5F5F5"
)
}
background_color = "white"
plot_margin = 0.025
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment