make_map: Produce map of continuous variable with gradient or Jenks...

View source: R/make_map.R

make_mapR Documentation

Produce map of continuous variable with gradient or Jenks breaks color scale.

Description

This function takes in data and produces a census tract map representing the variable using a gradient or discrete color scale. Should have "tractid10" column for census tracts.

Usage

make_map(
  data,
  var,
  region,
  shp_tracts,
  title = "Title",
  palette = "sequential",
  seq_colors = "YlOrRd",
  div_colors = "RdBu",
  jenksbreaks = F,
  manualbreaks = NULL,
  reverse = F,
  neg_bins = 3,
  pos_bins = 3,
  breaks = scales::extended_breaks(n = 6),
  labels = scales::percent,
  limits = NULL,
  coord = F,
  save = F,
  savename = "plot.png",
  caption = paste0(frb_caption, ses_caption, period_caption)
)

Arguments

data

Data with a "tractid10" column containing census tracts and variable of interest.

var

Name of column containing variable to plot.

region

The Bay Area region to map: "Bay Area", "San Francisco", "Oakland", "San Jose", "South Bay", "North Bay", or "East Bay"

shp_tracts

"US_tract_2010.shp" loaded object

title

Title of map

palette

Color palette: "sequential" (default) or "diverging"

seq_colors

Specific color scheme for sequential palette (e.g., "YlOrRd" (default), "Greens")

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)

reverse

Reverses color scale when T, otherwise uses default scale.

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

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

Value

Map of variable of interest across different groups.


Changing-Cities-Research-Lab/bayViz documentation built on Dec. 5, 2023, 12:06 p.m.