plotting

plotting

Core plotting functions for simulations, multisims, and scenarios.

Also includes Plotly-based plotting functions to supplement the Matplotlib based ones that are of the Sim and Scenarios objects. Intended mostly for use with the webapp.

Functions

Name Description
plot_compare Plot a MultiSim comparison – see MultiSim.plot_compare() for documentation
plot_people Plot statistics of a population – age distribution, numbers of contacts,
plot_result Plot a single result – see cv.Sim.plot_result() for documentation
plot_scens Plot the results of a scenario – see Scenarios.plot() for documentation
plot_sim Plot the results of a single simulation – see Sim.plot() for documentation
plotly_animate Plot an animation of each person in the sim
plotly_people Plot a “cascade” of people moving through different states
plotly_sim Main simulation results – parallel of sim.plot()

plot_compare

plotting.plot_compare(
    df,
    log_scale=True,
    fig_args=None,
    axis_args=None,
    style_args=None,
    fig=None,
    do_save=None,
    do_show=None,
    fig_path=None,
    **kwargs,
)

Plot a MultiSim comparison – see MultiSim.plot_compare() for documentation

plot_people

plotting.plot_people(
    people,
    bins=None,
    width=1.0,
    alpha=0.6,
    fig_args=None,
    axis_args=None,
    plot_args=None,
    style_args=None,
    do_show=None,
    fig=None,
)

Plot statistics of a population – age distribution, numbers of contacts, and overall weight of contacts (number of contacts multiplied by beta per layer).

Parameters

Name Type Description Default
people People the people to plot (e.g. sim.people); must be part of an initialized sim 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
style_args (dict) passed to cv.options.with_style() required
do_show (bool) whether to show the plot required
fig (fig) handle of existing figure to plot into required

Example::

sim = cv.Sim(pop_type='hybrid').init()
cv.plot_people(sim.people)

plot_result

plotting.plot_result(
    key,
    sim=None,
    fig_args=None,
    plot_args=None,
    axis_args=None,
    scatter_args=None,
    date_args=None,
    style_args=None,
    commaticks=True,
    setylim=True,
    color=None,
    label=None,
    do_show=None,
    do_save=False,
    fig_path=None,
    fig=None,
    ax=None,
    **kwargs,
)

Plot a single result – see cv.Sim.plot_result() for documentation

plot_scens

plotting.plot_scens(
    to_plot=None,
    scens=None,
    do_save=None,
    fig_path=None,
    fig_args=None,
    plot_args=None,
    scatter_args=None,
    axis_args=None,
    fill_args=None,
    legend_args=None,
    date_args=None,
    show_args=None,
    style_args=None,
    n_cols=None,
    commaticks=True,
    setylim=True,
    log_scale=False,
    colors=None,
    labels=None,
    do_show=None,
    sep_figs=False,
    fig=None,
    ax=None,
    **kwargs,
)

Plot the results of a scenario – see Scenarios.plot() for documentation

plot_sim

plotting.plot_sim(
    to_plot=None,
    sim=None,
    do_save=None,
    fig_path=None,
    fig_args=None,
    plot_args=None,
    scatter_args=None,
    axis_args=None,
    fill_args=None,
    legend_args=None,
    date_args=None,
    show_args=None,
    style_args=None,
    n_cols=None,
    commaticks=True,
    setylim=True,
    log_scale=False,
    colors=None,
    labels=None,
    do_show=None,
    sep_figs=False,
    fig=None,
    ax=None,
    **kwargs,
)

Plot the results of a single simulation – see Sim.plot() for documentation

plotly_animate

plotting.plotly_animate(sim, do_show=False)

Plot an animation of each person in the sim

plotly_people

plotting.plotly_people(sim, do_show=False)

Plot a “cascade” of people moving through different states

plotly_sim

plotting.plotly_sim(sim, do_show=False)

Main simulation results – parallel of sim.plot()