plot_site_reallocation_matrix

site_solutions.SolutionComparator.plot_site_reallocation_matrix(
    matrix=None,
    demand=None,
    config_a=None,
    config_b=None,
    by='demand',
    changed_only=False,
    cmap='Blues',
    annot=True,
    fmt=',.0f',
    figsize=(8, 6),
    title='default',
    caption=None,
    ax=None,
    **kwargs,
)

Heatmap of site_reallocation_matrix(): rows = set_a’s selected sites, columns = set_b’s, cell colour/annotation = the demand (or region count) whose closest site moved from that row’s site to that column’s site. A closed site’s row and a newly opened site’s column are the reallocation the table exists to show; the diagonal is the demand that stayed with the same site in both solutions. Both axes are ordered persisting sites first, then that axis’s own changed sites last (see site_reallocation_matrix), so the actual reallocation is grouped at the bottom/right rather than scattered wherever an unrelated unchanged site’s candidate index happens to fall.

Parameters

Name Type Description Default
matrix Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
demand Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
config_a Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
config_b Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
by Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
changed_only Passed straight through to site_reallocation_matrix(). changed_only=True drops every row/column that saw no reallocation at all, useful once the full matrix is too big (many unaffected sites) to scan comfortably as a heatmap. None
cmap str Colormap for the heatmap. Sequential rather than diverging – unlike plot_population_impact_map()’s travel-cost change, reallocated demand has no natural “centre” and is never negative. "Blues"
annot bool Whether to print each cell’s value on the heatmap (seaborn.heatmap’s own annot). True
fmt str Format string for the cell annotations. ",.0f"
figsize tuple Figure size, ignored if ax is given. (8, 6)
title str Title. If “default”, an automatic title naming set_a/set_b by their comparator labels is generated. "default"
caption str Explanatory text shown below the chart, wrapped to fit. If None (the default), a sensible stakeholder-facing caption explaining how to read the heatmap is generated; pass "" to suppress it, or a custom string to replace it. None
ax matplotlib.axes.Axes Existing Axes to draw into instead of creating a new figure. None
**kwargs dict Additional keyword arguments passed to seaborn.heatmap. {}

Returns

Name Type Description
(matplotlib.figure.Figure, matplotlib.axes.Axes)
Back to top