Map version of population_impact_worst_affected() – colours each demand location’s region by how its journey changed between set_a (baseline) and set_b (candidate), so a reader can see where an aggregate figure like “9,669 people worsened” actually falls, not just how many.
Requires a region_geometry_layer registered on set_b’s SiteProblem via add_region_geometry_layer().
Parameters
Name
Type
Description
Default
direction
(all, worsened, improved)
“all” colours every region by its signed change (delta, current_cost - baseline_cost) on a diverging scale centred on 0 – red for a longer journey, blue for a shorter one, white/pale for no meaningful change. This is the only mode where the scale is genuinely diverging, since it is the only one showing both directions at once. “worsened”/“improved” colour only that bucket (per population_impact_summary()’s meaningful_change_threshold -gated classification) on a plain sequential scale from 0 to the largest change in that direction; every other region is drawn in background_color for geographic context.
"all"
n
int
Restrict the coloured regions to the n most affected, exactly matching population_impact_worst_affected(n=n, direction=direction, ...) – the two are meant to be shown together. Only valid when direction is “worsened” or “improved”; raises ValueError alongside direction="all", since “all” already means “every region” and silently ignoring n there would be confusing.
None
matrix
Passed straight through to population_impact_summary().
None
demand
Passed straight through to population_impact_summary().
None
meaningful_change_threshold
Passed straight through to population_impact_summary().
None
config_a
Passed straight through to population_impact_summary().
None
config_b
Passed straight through to population_impact_summary().
None
cmap
str
Matplotlib colormap name. Defaults to "RdBu_r" for direction="all" (diverging: red=longer, blue=shorter), "Reds" for "worsened", "Blues" for "improved".
None
background_color
str
Fill colour for regions outside the coloured bucket. Ignored when direction="all", since every region is coloured there.
"#dddddd"
edgecolor
Region outline styling, applied to every region.
'black'
linewidth
Region outline styling, applied to every region.
'black'
show_sites
(None, all, closed)
Overlay candidate sites as points, using the same point geometry plot_best_combination() draws from (add_sites() with lat/long columns, or a geopandas input). None (default) draws no site markers. “all” plots every candidate site on set_b’s SiteProblem: sites closed relative to the baseline (in set_a’s selected solution but not set_b’s) are drawn as a distinct marker (closed_site_marker/closed_site_color/ closed_site_markersize); every other site (open in set_b, or never open in either solution) is drawn as a plain point (site_color/site_markersize). “closed” draws only the closed sites – the closure itself, without the clutter of every other site.
None
site_color
default "black", 40
Styling for open/context site markers (show_sites="all" only).
'black'
site_markersize
default "black", 40
Styling for open/context site markers (show_sites="all" only).
'black'
closed_site_color
'black'
closed_site_marker
'black'
closed_site_markersize
'black'
default
Styling for the closed-site markers. closed_site_marker’s shape (“X” vs site_color’s plain circle) is what distinguishes the two by default – deliberately not colour, since a red marker would clash with the “worsened”/“all” sequential and diverging red scales this plot itself uses. Pass a different closed_site_color (e.g. a bright colour not otherwise used by cmap) if the two need to stand apart more strongly, e.g. against a busy basemap.
required
figsize
tuple
Figure size, ignored if ax is given.
(9, 7)
title
str
Plot title. If “default”, an automatic title is generated.
"default"
legend
bool
Whether to draw a colour bar, labelled with the travel-time unit if one was set via add_travel_matrix(unit=...).
True
ax
matplotlib.axes.Axes
An existing Axes to draw into instead of creating a new figure – e.g. to embed this in a larger layout.
None
Returns
Name
Type
Description
(matplotlib.figure.Figure, matplotlib.axes.Axes)
Raises
Name
Type
Description
ValueError
If direction isn’t “all”/“worsened”/“improved”; if n is given alongside direction="all"; if show_sites isn’t None/“all”/“closed”; if show_sites is given but set_b’s SiteProblem has no point geometry on its candidate sites; if set_b’s SiteProblem has no region_geometry_layer registered; or any of the errors population_impact_summary() raises.