Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3997ebb

Browse files
authored
Merge pull request #27335 from story645/fix-stack
DOC: clarify stackplot limits
2 parents 62a5ba4 + 483fdb4 commit 3997ebb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

galleries/examples/lines_bars_and_markers/stackplot_demo.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
import matplotlib.pyplot as plt
1717
import numpy as np
1818

19+
import matplotlib.ticker as mticker
20+
1921
# data from United Nations World Population Prospects (Revision 2019)
2022
# https://population.un.org/wpp/, license: CC BY 3.0 IGO
2123
year = [1950, 1960, 1970, 1980, 1990, 2000, 2010, 2018]
2224
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],
2830
}
2931

3032
fig, ax = plt.subplots()
@@ -33,7 +35,9 @@
3335
ax.legend(loc='upper left', reverse=True)
3436
ax.set_title('World population')
3537
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))
3741

3842
plt.show()
3943

0 commit comments

Comments
 (0)