plot_ages#
- plot_ages(pop, **kwargs)[source]#
Plot a comparison of the expected and generated age distribution.
- Parameters:
pop (pop object) – population, either synthpops.pop.Pop, sp.people.People, or dict
**left (float) – Matplotlib.figure.subplot.left
**right (float) – Matplotlib.figure.subplot.right
**top (float) – Matplotlib.figure.subplot.top
**bottom (float) – Matplotlib.figure.subplot.bottom
**color_1 (str) – color for expected data
**color_2 (str) – color for data from generated population
**fontsize (float) – Matplotlib.figure.fontsize
**figname (str) – name to save figure to disk
**comparison (bool) – If True, plot comparison to the generated population
**do_show (bool) – If True, show the plot
**do_save (bool) – If True, save the plot to disk
- Returns:
Matplotlib figure and axes.
Note
If using pop with type sp.people.Pop or dict, args must be supplied for the location parameters to get the expected distribution.
Example:
pars = {'n': 10e3, 'location':'seattle_metro', 'state_location':'Washington', 'country_location':'usa'} pop = sp.Pop(**pars) fig, ax = pop.plot_age_distribution_comparison() popdict = pop.to_dict() kwargs = pars.copy() kwargs['datadir'] = sp.datadir fig, ax = sp.plot_age_distribution_comparison(popdict, **kwargs)