Plots the full map of Spain at the requested geographic level (provinces or municipalities), with one or more regions highlighted in a different color. Useful for confirming which regions a region filter passed to get_ine_demog() or get_ine_geo() actually matches, since get_ine_geo() uses regex substring matching by default (see vignette examples in test_cordoba.R).

plot_ine_map(
  geo_level = c("province", "municipality"),
  highlight = NULL,
  base_color = "grey90",
  highlight_color = "firebrick",
  title = NULL,
  can_box = TRUE,
  can_gap_km = 60
)

Arguments

geo_level

Character, one of "province" or "municipality".

highlight

Character vector of region names to highlight (regular expressions allowed, matched against the geography name — same matching rules as region in get_ine_demog()/get_ine_geo()). If NULL (default), the whole map is plotted in base_color with no highlighting.

base_color

Fill color for non-highlighted regions. Default "grey90".

highlight_color

Fill color for highlighted regions. Default "firebrick".

title

Optional plot title.

can_box

Logical, draw an inset separator box around the Canary Islands, which are shifted next to the mainland for a compact map (default TRUE).

can_gap_km

Numeric, how close (in km) the shifted Canary Islands sit next to the mainland (default 60). Smaller values move them closer. See get_ine_geo().

Value

A ggplot object.

Examples

if (FALSE) { # \dontrun{
# Not run: get_ine_geo() requires live network access to fetch boundaries.
plot_ine_map(geo_level = "province", highlight = "^Córdoba$")
plot_ine_map(geo_level = "municipality", highlight = "Córdoba")
} # }