
Two-Panel LISA Visualisation: Cluster Map and Moran Scatter Plot
Source:R/sus_mod_plot_spatial_moran.R
sus_mod_plot_spatial_moran.RdProduces 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_moranobject fromsus_mod_spatial_moran().- municipalities
An
sfobject with at least the columncode_muni(7-digit IBGE code) and polygon geometry. Required whentypeis"map"or"both". Ignored fortype = "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. DefaultNULL.- lang
Character. Output language:
"pt"(default),"en", or"es".- ...
Additional arguments passed to
ggplot2::ggsave()when saving, or ignored.
Value
type = "map"-> aggplotobject.type = "scatter"-> aggplotobject.type = "both"-> apatchwork/ggplotcombined object, or a named listlist(map = <ggplot>, scatter = <ggplot>)if patchwork is not installed.
Panel types (type)
type | Description |
"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")
} # }