Skip to contents

Produces a choropleth LISA cluster map and/or a Moran scatter plot from a climasus_spatial_moran object returned by sus_mod_spatial_moran().

Usage

sus_mod_plot_spatial_moran(
  x,
  municipalities = NULL,
  type = c("map", "scatter", "both"),
  alpha = 0.05,
  title = NULL,
  lang = "pt",
  ...
)

Arguments

x

A climasus_spatial_moran object from sus_mod_spatial_moran().

municipalities

An sf object with at least the column code_muni (7-digit IBGE code) and polygon geometry. Required when type is "map" or "both". Ignored for type = "scatter".

type

Character. Which panel(s) to produce. One of "map" (default), "scatter", or "both".

alpha

Numeric in (0, 1). Significance level used for the subtitle annotation. Default 0.05.

title

Character or NULL. Custom title overriding the default translated title. Applies to the first / only panel. Default NULL.

lang

Character. Output language: "pt" (default), "en", or "es".

...

Additional arguments passed to ggplot2::ggsave() when saving, or ignored.

Value

  • type = "map" -> a ggplot object.

  • type = "scatter" -> a ggplot object.

  • type = "both" -> a patchwork / ggplot combined object, or a named list list(map = <ggplot>, scatter = <ggplot>) if patchwork is not installed.

Panel types (type)

typeDescription
"map"Choropleth map coloured by LISA quadrant (HH/LL/HL/LH/NS).
"scatter"Moran scatter plot of standardised values vs. spatial lag.
"both"Side-by-side panels via patchwork (named list fallback if not installed).

Colour scheme

Quadrant colours follow the conventional LISA palette: HH = "red3", LL = "blue3", HL = "darkorange", LH = "steelblue", NS = "grey80".

Examples

if (FALSE) { # \dontrun{
# Requires spdep, sf, ggplot2 (and optionally patchwork)
library(climasus4r)

# moran_res <- sus_mod_spatial_moran(df, "deaths", W)
# shp <- geobr::read_municipality(code_muni = "all", year = 2020)

sus_mod_plot_spatial_moran(moran_res, municipalities = shp, type = "both")
sus_mod_plot_spatial_moran(moran_res, municipalities = shp, type = "map", lang = "en")
sus_mod_plot_spatial_moran(moran_res, type = "scatter", lang = "es")
} # }