plot_site_allocation_summary

site.SiteSolutionSet.plot_site_allocation_summary(
    by='demand',
    metric='proportion',
    sort_by=None,
    solution_rank=1,
    site_names=None,
    site_indices=None,
    matrix=None,
    demand=None,
    interactive=True,
    sort=True,
    cmap='Set2',
    site_color_map=None,
    title='default',
    x_axis_label='default',
    y_axis_label='default',
    interactive_width=800,
    interactive_height=600,
    static_width=10,
    static_height=6,
)

Bar chart of site_allocation_summary() for one chosen solution.

Parameters

Name Type Description Default
by Passed straight through to site_allocation_summary(). 'demand'
sort_by Passed straight through to site_allocation_summary(). 'demand'
solution_rank Passed straight through to site_allocation_summary(). 'demand'
site_names Passed straight through to site_allocation_summary(). 'demand'
site_indices Passed straight through to site_allocation_summary(). 'demand'
matrix Passed straight through to site_allocation_summary(). 'demand'
demand Passed straight through to site_allocation_summary(). 'demand'
metric (proportion, allocated_demand, n_regions, average_travel_cost) Which site_allocation_summary() column to plot. “proportion” shows the share of demand (or of regions) closest to each site. “allocated_demand” shows the raw headcount allocated to each site instead of its share – requires demand data (see Raises); use “n_regions” to count regions instead when no demand is registered. Note by= has no effect on “allocated_demand” or “n_regions”: both are already an absolute count, not a share, so there is nothing for “regions” vs “demand” to switch between (that distinction only applies to “proportion” and “average_travel_cost”). “average_travel_cost” shows the average travel cost incurred by each site’s group instead – e.g. to see how much further people would have to travel if a site were closed. This is the comparison inspired by Gill Baker’s work using average travel distance per patient to show that centralising services would roughly double typical travel distance (see site_allocation_summary for the full story). "proportion"
interactive bool If True, generates an interactive Plotly bar chart. If False, generates a static Matplotlib bar chart. True
sort bool If True, bars are ordered ascending by metric, so the smallest-catchment (or shortest-travel) site – usually the one being investigated – is at the top. If False, sites keep canonical site-index order, useful when lining this chart up against another figure built in that order. True
cmap str Colormap for sites closest to at least one region, matching plot_best_combination(plot_site_allocation=True). Sites closest to no region are coloured grey rather than drawn from this colormap, since they colour no regions on that map either. "Set2"
site_color_map dict Explicit {site_name: color} mapping, e.g. one already built for a companion map, so the two figures share identical colours. Sites not present in this mapping are coloured grey. None

Returns

Name Type Description
plotly.graph_objects.Figure or matplotlib.figure.Figure The generated bar chart. Returns a Plotly Figure if interactive=True, otherwise a Matplotlib Figure.

Notes

With metric="proportion", a zero-allocation site’s bar has zero length and would otherwise be invisible, so every bar is always labelled with its percentage value – that label is how a 0% site stays visible on the chart at all.

With metric="average_travel_cost", a zero-allocation site has no travel cost to average (NaN in site_allocation_summary()), so its bar is drawn at zero length but labelled “N/A” rather than a number – a “0” label there would misleadingly read as “instant to reach” rather than “not applicable”.

Back to top