visualizers

visualizers

A collection of useful plotting functions that could eventually be part of some class such as People, Network or Analyzer.

Functions

Name Description
plot_age_histogram Plot population age distribution
plot_age_mixing Plot the empirical age mixing matrix and optionally the
plot_calib Plot all results in the Sim object after the simulation has run
plot_sim Plot all results in the Sim object after the simulation has run

plot_age_histogram

visualizers.plot_age_histogram(
    people,
    bins=None,
    width=1.0,
    alpha=0.6,
    fig_args=None,
    axis_args=None,
    plot_args=None,
    fig=None,
)

Plot population age distribution

Parameters

Name Type Description Default
people starsim People the people object. Must be intialized. required
bins (arr) age bins to use (default, 0-100 in one-year bins) required
width (float) bar width required
alpha (float) transparency of the plots required
fig_args (dict) passed to pl.figure() required
axis_args (dict) passed to pl.subplots_adjust() required
plot_args (dict) passed to pl.plot() required
fig (fig) handle of existing figure to plot into required

Returns

Name Type Description
fig (fig) : handle of figure where data has been plotted

plot_age_mixing

visualizers.plot_age_mixing(network, fig_args=None, axis_args=None, fig=None)

Plot the empirical age mixing matrix and optionally the simulated age mixing matrix.

Parameters

Name Type Description Default
location (str) the geographical location of the age mixing we want to plot required
network starsim Network the network object,must be intialized and must be an instance of CommunityNet. required
fig_args (dict) passed to pl.figure() required
axis_args (dict) passed to pl.subplots_adjust() required
fig (fig) handle of existing figure to plot into required

Returns

Name Type Description
fig (fig) : handle of figure where data has been plotted

plot_calib

visualizers.plot_calib(
    calib,
    fig=None,
    style='fancy',
    fig_kw=None,
    plot_kw=None,
    timevec=None,
    display_from=None,
    display_until=None,
)

Plot all results in the Sim object after the simulation has run

Parameters

Name Type Description Default
calib typhoidsim.Calibration220 a Calibration object for which check_fit() has been run required
key str the timepoint to plot (by default, all) required
fig Figure if provided, plot results into an existing figure None
style str the plotting style to use (default “fancy”; other options are “simple”, None, or any Matplotlib style) 'fancy'
fig_kw dict passed to plt.subplots() None
plot_kw dict passed to plt.plot() None
time arr the time vector (in years) we want to use for plotting the results, defaults to sim.timevec required

plot_sim

visualizers.plot_sim(
    sim,
    key=None,
    fig=None,
    style='fancy',
    fig_kw=None,
    plot_kw=None,
    timevec=None,
    display_from=None,
    display_until=None,
)

Plot all results in the Sim object after the simulation has run

Parameters

Name Type Description Default
key str the results key to plot (by default, all) None
fig Figure if provided, plot results into an existing figure None
style str the plotting style to use (default “fancy”; other options are “simple”, None, or any Matplotlib style) 'fancy'
fig_kw dict passed to plt.subplots() None
plot_kw dict passed to plt.plot() None
timevec arr the time vector (in years) we want to use for plotting the results, defaults to sim.timevec None