You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lecture looks at different growth trajectories across countries over the long term.
@@ -40,13 +30,16 @@ import numpy as np
40
30
from matplotlib.lines import Line2D
41
31
```
42
32
33
+
## Setting up
34
+
35
+
+++
43
36
44
37
A project initiated by [Angus Maddison](https://en.wikipedia.org/wiki/Angus_Maddison) has collected many historical time series that study economic growth.
45
38
46
39
We can use the [Maddison Historical Statistics](https://www.rug.nl/ggdc/historicaldevelopment/maddison/) to look at many different countries, including some countries dating back to the first century.
47
40
48
41
```{tip}
49
-
The data can be downloaded from [this webpage](https://www.rug.nl/ggdc/historicaldevelopment/maddison/) and clicking on the `Latest Maddison Project Release`. In this lecture we use the [Maddison Project Database 2020](https://www.rug.nl/ggdc/historicaldevelopment/maddison/releases/maddison-project-database-2020) using the `Excel` Format. The code we use here assumes you have downloaded that file and will teach you how to use [pandas](https://pandas.pydata.org) to import that data into a DataFrame.
42
+
The data can be downloaded from [this webpage](https://www.rug.nl/ggdc/historicaldevelopment/maddison/) and clicking on the `Latest Maddison Project Release`. In this lecture we use the [Maddison Project Database 2020](https://www.rug.nl/ggdc/historicaldevelopment/maddison/releases/maddison-project-database-2020) using the `Excel` Format.
50
43
```
51
44
52
45
If you don't want to fetch the data file from [Maddison Historical Statistics](https://www.rug.nl/ggdc/historicaldevelopment/maddison/) you can download the file directly {download}`datasets/mpd2020.xlsx`.
@@ -60,10 +53,6 @@ We can see that this dataset contains GDP per capita (gdppc) and population (pop
60
53
61
54
Let's look at how many and which countries are available in this dataset
62
55
63
-
```{code-cell} ipython3
64
-
data.country.unique()
65
-
```
66
-
67
56
```{code-cell} ipython3
68
57
len(data.country.unique())
69
58
```
@@ -102,6 +91,20 @@ Then we can quickly focus on GDP per capita (gdp)
102
91
data
103
92
```
104
93
94
+
```{code-cell} ipython3
95
+
import matplotlib.pyplot as plt
96
+
import matplotlib.cm as cm
97
+
import numpy as np
98
+
99
+
country_names = data['countrycode']
100
+
101
+
# Generate a colormap with the number of colors matching the number of countries
Looking at the United Kingdom we can first confirm we are using the correct country code
115
118
116
-
```{code-cell} ipython3
117
-
code_to_name.loc['GBR']
118
-
```
119
-
120
-
and then using that code to access and plot the data
121
-
122
119
```{code-cell} ipython3
123
120
---
124
121
mystnb:
125
122
figure:
126
123
caption: GDP per Capita (GBR)
127
124
name: gdppc_gbr1
128
125
---
129
-
fig = plt.figure()
130
-
gdppc['GBR'].plot(ax = fig.gca())
131
-
plt.show()
126
+
fig, ax = plt.subplots(dpi=300)
127
+
cntry = 'GBR'
128
+
_ = gdppc[cntry].plot(
129
+
ax = fig.gca(),
130
+
ylabel = 'International $\'s',
131
+
xlabel = 'Year',
132
+
linestyle='-',
133
+
color=color_mapping['GBR'])
132
134
```
133
135
134
136
We can see that the data is non-continuous for longer periods in early part of this milenium so we could choose to interpolate to get a continuous line plot.
135
137
138
+
Here we use dashed lines to indicate interpolated trends
139
+
136
140
```{code-cell} ipython3
137
141
---
138
142
mystnb:
139
143
figure:
140
144
caption: GDP per Capita (GBR)
141
145
name: gdppc_gbr2
142
146
---
143
-
fig= plt.figure(dpi=300)
147
+
fig, ax = plt.subplots(dpi=300)
144
148
cntry = 'GBR'
145
-
gdppc[cntry].interpolate().plot(
146
-
ax = fig.gca(),
147
-
ylabel = 'International $\'s',
148
-
xlabel = 'Year'
149
-
)
149
+
ax.plot(gdppc[cntry].interpolate(),
150
+
linestyle='--',
151
+
lw=2,
152
+
color=color_mapping[cntry])
153
+
154
+
ax.plot(gdppc[cntry],
155
+
linestyle='-',
156
+
lw=2,
157
+
color=color_mapping[cntry])
158
+
ax.set_ylabel('International $\'s')
159
+
ax.set_xlabel('Year')
150
160
plt.show()
151
161
```
152
162
163
+
We can now put this into a function to generate plots for a list of countries
[International Dollars](https://en.wikipedia.org/wiki/International_dollar) are a hypothetical unit of currency that has the same purchasing power parity that the U.S. Dollar has in the United States and any given time. They are also known as Geary–Khamis dollar (GK Dollars).
155
197
:::
@@ -165,55 +207,41 @@ mystnb:
165
207
caption: GDP per Capita
166
208
name: gdppc_usa_gbr_chn
167
209
---
168
-
fig = plt.figure(dpi=300)
169
-
ax = fig.gca()
170
-
cntry = ['USA', 'GBR', 'CHN']
171
-
line_color = ['blue', 'orange', 'green']
172
-
gdppc[cntry].plot(
173
-
ax = ax,
174
-
ylabel = 'International $\'s',
175
-
xlabel = 'Year',
176
-
color = line_color
177
-
)
178
-
179
-
# Build Custom Legend
180
-
legend_elements = []
181
-
for i,c in enumerate(cntry):
182
-
line = Line2D([0], [0], color=line_color[i], lw=2, label=code_to_name.loc[c]['country'])
As you can see the countries had similar GDP per capita levels with divergence starting around 1940. Australia's growth experience is both more continuous and less volatile post 1940.
0 commit comments