|
16 | 16 | import matplotlib.pyplot as plt
|
17 | 17 | import numpy as np
|
18 | 18 |
|
| 19 | +import matplotlib.ticker as mticker |
| 20 | + |
19 | 21 | # data from United Nations World Population Prospects (Revision 2019)
|
20 | 22 | # https://population.un.org/wpp/, license: CC BY 3.0 IGO
|
21 | 23 | year = [1950, 1960, 1970, 1980, 1990, 2000, 2010, 2018]
|
22 | 24 | population_by_continent = {
|
23 |
| - 'africa': [228, 284, 365, 477, 631, 814, 1044, 1275], |
24 |
| - 'americas': [340, 425, 519, 619, 727, 840, 943, 1006], |
25 |
| - 'asia': [1394, 1686, 2120, 2625, 3202, 3714, 4169, 4560], |
26 |
| - 'europe': [220, 253, 276, 295, 310, 303, 294, 293], |
27 |
| - 'oceania': [12, 15, 19, 22, 26, 31, 36, 39], |
| 25 | + 'Africa': [.228, .284, .365, .477, .631, .814, 1.044, 1.275], |
| 26 | + 'the Americas': [.340, .425, .519, .619, .727, .840, .943, 1.006], |
| 27 | + 'Asia': [1.394, 1.686, 2.120, 2.625, 3.202, 3.714, 4.169, 4.560], |
| 28 | + 'Europe': [.220, .253, .276, .295, .310, .303, .294, .293], |
| 29 | + 'Oceania': [.012, .015, .019, .022, .026, .031, .036, .039], |
28 | 30 | }
|
29 | 31 |
|
30 | 32 | fig, ax = plt.subplots()
|
|
33 | 35 | ax.legend(loc='upper left', reverse=True)
|
34 | 36 | ax.set_title('World population')
|
35 | 37 | ax.set_xlabel('Year')
|
36 |
| -ax.set_ylabel('Number of people (millions)') |
| 38 | +ax.set_ylabel('Number of people (billions)') |
| 39 | +# add tick at every 200 million people |
| 40 | +ax.yaxis.set_minor_locator(mticker.MultipleLocator(.2)) |
37 | 41 |
|
38 | 42 | plt.show()
|
39 | 43 |
|
|
0 commit comments