This function builds a choropleth plot given user specifications using ggplot2.

buildMapPlot(df, y, facet = "none", scaleLabels = waiver(),
  title = NULL)

Arguments

df

A data frame with plot data

y

Name of fill variable (string)

facet

Name of facet variable (string)

scaleLabels

Scale labels for y-variable (e.g., waiver(), scales::percent). This value is passed to the scale_fill_viridis function.

title

Title of plot (string)

Value

A ggplot2 plot object

Details

The plot labels are based on variable names. The to_any_case function is used to convert variable names from the data frame in camel case to sentence case.

If the fill variable is "permits" or "customers", then the data is log transformed automatically.

The y-axis labels are repeated for each subplot using the facet_rep_wrap function.