src.plotting.plotting

Module Contents

Functions

calculate_virus_strain_shares(results)

Create the weekly incidences from a list of simulation runs.

plot_incidences(incidences, title, name_to_label, colors, n_single_runs: Optional[int] = 0, scenario_starts=None, fig=None, ax=None, ylabel=None)

Plot incidences.

plot_share_known_cases(share_known_cases, title, groupby, plot_single_runs=False)

plot_group_time_series(df, title, rki=None, ylabel=None)

Plot a time series by group with more than one run.

style_plot(fig, axes)

format_date_axis(ax)

shorten_dfs(dfs, plot_start=None, plot_end=None)

Shorten all incidence DataFrames.

create_automatic_labels(names)

make_scenario_name_nice(name)

Make a scenario name nice.

make_nice_outcome(outcome)

Attributes

BLUE = #4e79a7[source]
ORANGE = #f28e2b[source]
RED = #e15759[source]
TEAL = #76b7b2[source]
GREEN = #59a14f[source]
YELLOW = #edc948[source]
PURPLE = #b07aa1[source]
BROWN = #9c755f[source]
UNORDERED_COLORS[source]
ORDERED_COLORS[source]
OUTCOME_TO_EMPIRICAL_LABEL[source]
OUTCOME_TO_Y_LABEL[source]
calculate_virus_strain_shares(results)[source]

Create the weekly incidences from a list of simulation runs.

Parameters

results (list) – list of DataFrames with the time series data from sid simulations.

Returns

every column is the

weekly incidence over time for one simulation run. The index are the dates of the simulation period.

Return type

virus_strain_shares (pandas.DataFrame)

plot_incidences(incidences, title, name_to_label, colors, n_single_runs: Optional[int] = 0, scenario_starts=None, fig=None, ax=None, ylabel=None)[source]

Plot incidences.

Parameters
  • incidences (dict) – keys are names of the scenarios, values are dataframes where each column is the incidence of interest of one run

  • title (str) – plot title.

  • name_to_label (dict) – keys must contain the ones in incidences. Values will be plotted as labels of the scenarios in the figure’s legend.

  • n_single_runs (Optional[int or None]) – Number of individual runs with different seeds visualize to show statistical uncertainty. Passing None will plot all runs.

  • scenario_starts (list, optional) – the scenario start points. Each consists of a tuple of the date and a label.

  • ylabel (str, optional) – Label of the y axis.

Returns

fig, ax

plot_share_known_cases(share_known_cases, title, groupby, plot_single_runs=False)[source]
plot_group_time_series(df, title, rki=None, ylabel=None)[source]

Plot a time series by group with more than one run.

Parameters
  • df (pandas.DataFrame) – index levels are dates and group identifiers. There is one column for each simulation run.

  • title (str) – the title of the plot

  • rki (pandas.Series, optional) – Series with the RKI data. Must have the same index as df.

  • ylabel (str, optional) – label of the y axis.

style_plot(fig, axes)[source]
format_date_axis(ax)[source]
shorten_dfs(dfs, plot_start=None, plot_end=None)[source]

Shorten all incidence DataFrames.

All DataFrames are shortened to the shortest. In addition, if plot_start is given all DataFrames start at or after plot_start.

Parameters
  • dfs (dict) – keys are the names of the scenarios, values are the incidence DataFrames.

  • plot_start (pd.Timestamp or None) – earliest allowed start date for the plot

  • plot_start – latest allowed end date for the plot

Returns

keys are the names of the scenarios, values are the shortened

DataFrames.

Return type

shortened (dict)

create_automatic_labels(names)[source]
make_scenario_name_nice(name)[source]

Make a scenario name nice.

Parameters

name (str) – name of the scenario

Returns

nice name of the scenario

Return type

nice_name (str)

make_nice_outcome(outcome)[source]