Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vulnerability-indicators
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
VizLab
vulnerability-indicators
Commits
a871a09e
Commit
a871a09e
authored
7 months ago
by
Azadpour, Elmera
Browse files
Options
Downloads
Patches
Plain Diff
update census maps leg labels
parent
ba13441f
No related branches found
No related tags found
1 merge request
!62
Edits from Joe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
3_visualize.R
+5
-0
5 additions, 0 deletions
3_visualize.R
3_visualize/src/plot_utils.R
+13
-8
13 additions, 8 deletions
3_visualize/src/plot_utils.R
with
18 additions
and
8 deletions
3_visualize.R
+
5
−
0
View file @
a871a09e
...
...
@@ -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'
,
...
...
This diff is collapsed.
Click to expand it.
3_visualize/src/plot_utils.R
+
13
−
8
View file @
a871a09e
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment