View source: R/make_map_panel.R
make_map_panel | R Documentation |
This function takes in data and produces a panel of census tract maps representing the variable using a gradient or discrete color scale. Should have "tractid10" column for census tracts and "group" column containing up to 6 distinct values. If "group" column is geographic regions, then "region" parameter can be ignored.
make_map_panel(
data,
var,
region = NULL,
shp_tracts,
palette = "sequential",
div_colors = "RdPu",
jenksbreaks = F,
manualbreaks = NULL,
neg_bins = 3,
pos_bins = 3,
breaks = scales::extended_breaks(n = 6),
labels = scales::percent,
colorscale = "colorbar",
limits = NULL,
coord = F,
save = F,
savename = "plot.png",
caption = paste0(frb_caption, ses_caption, period_caption)
)
data |
Data with a "tractid10" column containing census tracts, "group" column containing panel titles; and variable of interest. |
var |
Name of column containing variable to plot. |
region |
If "group" column is not geographic region names, supply name of region to map for entire panel: "Bay Area", "San Francisco", "Oakland", "San Jose", "South Bay", "North Bay", or "East Bay" |
shp_tracts |
"US_tract_2010.shp" loaded object |
palette |
Color palette: "sequential" (default) or "diverging" |
div_colors |
Specific color scheme for diverging palette. Defaults to "RdBu" |
jenksbreaks |
Uses Jenks Breaks when T, otherwise uses continuous color scale |
manualbreaks |
Numeric vector of breaks for a discrete color scale. Defaults to continuous scale (or uses jenks breaks if true) |
neg_bins |
For Jenks breaks, number of negative color bins. Default is 3. |
pos_bins |
For Jenks breaks, number of positive color bins. Default is 3. |
breaks |
Gradient scale breaks, either numeric vector or scales::extended_breaks(n = 6) |
labels |
Gradient scale labels, either character vector or scales::percent or scales::comma |
colorscale |
Format of color key, either "colorbar" or "legend". Default is "colorbar". |
limits |
Gradient scale limits, c(min, max) |
coord |
T if plotting coordinate values (data frame must contain "lat", "lon" columns). Default is F. |
save |
T if user would like to return plot object and save file, F (default) to just return object. |
savename |
File name of map for saving. |
caption |
Figure caption |
Map panel of variable of interest across different groups.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.