class age_pyramid(timepoints=None, *args, edges=None, age_labels=None, datafile=None, die=False, **kwargs)[source]#

Bases: Analyzer

Constructs an age/sex pyramid at specified points within the sim. Can be used with data

  • timepoints (list) – list of ints/strings/date objects, the days on which to take the snapshot

  • die (bool) – whether or not to raise an exception if a date is not found (default true)

  • kwargs (dict) – passed to Analyzer()


sim = hpv.Sim(analyzers=hpv.age_pyramid('2015', '2020'))
age_pyramid = sim['analyzers'][0]


static reduce(analyzers, use_mean=False, bounds=None, quantiles=None)[source]#

Create an averaged age pyramid from a list of age pyramid analyzers

plot(m_color='#4682b4', f_color='#ee7989', fig_args=None, axis_args=None, data_args=None, percentages=True, do_save=None, fig_path=None, do_show=True, **kwargs)[source]#

Plot the age pyramids

  • m_color (hex or rgb) – the color of the bars for males

  • f_color (hex or rgb) – the color of the bars for females

  • fig_args (dict) – passed to pl.figure()

  • axis_args (dict) – passed to pl.subplots_adjust()

  • data_args (dict) – ‘width’, ‘color’, and ‘offset’ arguments for the data

  • percentages (bool) – whether to plot the pyramid as percentages or numbers

  • do_save (bool) – whether to save

  • fig_path (str or filepath) – filepath to save to

  • do_show (bool) – whether to show the figure

  • kwargs (dict) – passed to hpv.options.with_style(); see that function for choices