plot_accessibility

site.SiteProblem.plot_accessibility(
    region_frame=None,
    site_frame=None,
    supply_col=None,
    catchment_size=None,
    distance_decay=None,
    site_names=None,
    site_indices=None,
    matrix=None,
    per_capita=1,
    interactive=False,
    cmap='Blues',
    show_site_ratio=False,
    site_colour='black',
    site_marker_size=60,
    site_cmap='RdYlGn',
    missing_site_colour='lightgrey',
    marker_size_range=(40, 220),
    edgecolor='black',
    linewidth=0.5,
    tiles='CartoDB positron',
    add_basemap=True,
    show_axis=False,
    title=None,
    caption=None,
    ax=None,
    figsize=None,
    **kwargs,
)

Map 2SFCA accessibility: a region choropleth of accessibility, overlaid with site markers. By default the markers are plain, uniformly coloured/sized location dots – pass show_site_ratio=True to instead colour and size them by their step-1 supply-to-demand ratio, so a map reader can see both where access is poor and which site is driving it (an overloaded, low-ratio site drawn small and red) in one view. The ratio view is opt-in because it’s easy to misread as a raw capacity/ overutilisation metric, when it’s actually a relative figure specific to the chosen catchment_size/distance_decay.

Parameters

Name Type Description Default
region_frame pandas.DataFrame The two tables returned by two_step_floating_catchment(return_site_ratios=True). If either is None (the default), both are computed automatically from supply_col/catchment_size and the selection arguments below. None
site_frame pandas.DataFrame The two tables returned by two_step_floating_catchment(return_site_ratios=True). If either is None (the default), both are computed automatically from supply_col/catchment_size and the selection arguments below. None
supply_col None
catchment_size None
distance_decay None
site_names None
site_indices None
matrix Forwarded to two_step_floating_catchment() when region_frame/site_frame are not supplied; see that method’s docstring (catchment_size/distance_decay are mutually exclusive there too). On a SiteSolutionSet, this always scores solution_rank=1 – to plot a specific sort_by/solution_rank solution, call two_step_floating_catchment(..., return_site_ratios=True) yourself and pass the results in as region_frame/site_frame. None
per_capita Forwarded to two_step_floating_catchment() when region_frame/site_frame are not supplied; see that method’s docstring (catchment_size/distance_decay are mutually exclusive there too). On a SiteSolutionSet, this always scores solution_rank=1 – to plot a specific sort_by/solution_rank solution, call two_step_floating_catchment(..., return_site_ratios=True) yourself and pass the results in as region_frame/site_frame. None
interactive bool If True, returns an interactive Folium map via .explore(). Otherwise returns a static matplotlib Axes. False
cmap str Colormap for the region choropleth (accessibility). "Blues"
show_site_ratio bool If False (the default), site markers are plain, uniformly coloured/sized location dots (site_colour/site_marker_size control their appearance). If True, markers are instead coloured and sized by their step-1 supply-to-demand ratio – see site_cmap/missing_site_colour/marker_size_range, which only apply in this mode. False
site_colour str Marker colour for site markers when show_site_ratio=False. "black"
site_marker_size float Static marker size for site markers when show_site_ratio=False. Ignored on interactive maps, where Folium markers are a fixed size. 60
site_cmap str Colormap for site markers (ratio) when show_site_ratio=True – red for an overloaded, low-ratio site, green for a relatively uncontested one. "RdYlGn"
missing_site_colour str When show_site_ratio=True: colour (and static marker size, at the smallest of marker_size_range) for a site with an undefined ratio – no demand fell within its catchment, so there is nothing to colour or size it by. "lightgrey"
marker_size_range tuple of (float, float) When show_site_ratio=True: smallest and largest static marker size, linearly scaled by ratio. Ignored on interactive maps, where Folium markers are a fixed size. (40, 220)
add_basemap bool If True, adds a background web map. Set False to skip the tile download entirely. True
title str Axes title. Ignored on interactive maps. None
caption str Explanatory text shown below the chart, wrapped to fit. If None (the default), a stakeholder-facing caption explaining how to read the region shading – and, depending on show_site_ratio, either that the site markers are plain location dots or how to read their colour/size – is generated; pass "" to suppress it, or a custom string to replace it. Ignored on interactive maps. None
ax matplotlib.axes.Axes Existing axes to plot onto. Ignored if interactive=True. None
figsize tuple Passed to plt.subplots() if ax is not supplied. Ignored if interactive=True. None
**kwargs dict Additional keyword arguments passed to the region choropleth’s plotting call (GeoDataFrame.plot/.explore). {}

Returns

Name Type Description
matplotlib.axes.Axes or folium.Map

Raises

Name Type Description
ValueError If neither region_frame/site_frame nor supply_col plus one of catchment_size/distance_decay are supplied, or if no region geometry layer has been registered via add_region_geometry_layer().

Notes

Site markers are only drawn if candidate_sites was registered with real geometry (i.e. add_sites() was given a GeoDataFrame or lat/long columns, not a bare site list derived from the travel matrix’s column names) – otherwise only the region choropleth is shown.

Back to top