@@ -250,7 +250,7 @@ def process_df(df):
250
250
251
251
return df
252
252
253
- def create_plot (p_seq, e_seq, index, labs, ax):
253
+ def create_pe_plot (p_seq, e_seq, index, labs, ax):
254
254
255
255
p_lab, e_lab = labs
256
256
@@ -273,6 +273,28 @@ def create_plot(p_seq, e_seq, index, labs, ax):
273
273
ax1.legend(loc='upper left')
274
274
275
275
return ax1
276
+
277
+ def create_pr_plot(p_seq, index, ax):
278
+
279
+ # Calculate the difference of log p_seq
280
+ log_diff_p_seq = np.diff(np.log(p_seq))
281
+
282
+ # Graph for the difference of log p_seq
283
+ ax.scatter(index[1:], log_diff_p_seq, label='Monthly Inflation Rate', color='tab:grey')
284
+ diff_smooth = pd.DataFrame(log_diff_p_seq).rolling(3).mean()
285
+ ax.plot(index[1:], diff_smooth, alpha=0.5, color='tab:grey')
286
+ ax.text(-0.08, 1.03, 'Monthly Inflation Rate', transform=ax.transAxes)
287
+
288
+ ax.xaxis.set_major_locator(mdates.MonthLocator(interval=5))
289
+ ax.xaxis.set_major_formatter(mdates.DateFormatter('%b %Y'))
290
+
291
+ for label in ax.get_xticklabels():
292
+ label.set_rotation(45)
293
+
294
+ ax.legend(loc='upper left')
295
+
296
+ return ax
297
+
276
298
```
277
299
278
300
``` {code-cell} ipython3
@@ -319,13 +341,21 @@ lab = ['Retail Price Index', 'Exchange Rate']
319
341
320
342
# create plot
321
343
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
322
- _ = create_plot (p_seq, e_seq, df_Aus.index, lab, ax)
344
+ _ = create_pe_plot (p_seq, e_seq, df_Aus.index, lab, ax)
323
345
324
346
# connect disjunct parts
325
347
plt.figtext(0.5, -0.02, 'Austria', horizontalalignment='center', fontsize=12)
326
348
plt.show()
327
349
```
328
350
351
+ ``` {code-cell} ipython3
352
+ fig, ax = plt.subplots(figsize=[10,7], dpi=200)
353
+ _ = create_pr_plot(p_seq, df_Aus.index, ax)
354
+
355
+ plt.figtext(0.5, -0.02, 'Austria', horizontalalignment='center', fontsize=12)
356
+ plt.show()
357
+ ```
358
+
329
359
### Hungary
330
360
331
361
The source of our data for Hungary is:
@@ -346,7 +376,15 @@ lab = ['Hungarian Index of Prices', '1/Cents per Crown in New York']
346
376
347
377
# create plot
348
378
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
349
- _ = create_plot(p_seq, e_seq, df_Hung.index, lab, ax)
379
+ _ = create_pe_plot(p_seq, e_seq, df_Hung.index, lab, ax)
380
+
381
+ plt.figtext(0.5, -0.02, 'Hungary', horizontalalignment='center', fontsize=12)
382
+ plt.show()
383
+ ```
384
+
385
+ ``` {code-cell} ipython3
386
+ fig, ax = plt.subplots(figsize=[10,7], dpi=200)
387
+ _ = create_pr_plot(p_seq, df_Hung.index, ax)
350
388
351
389
plt.figtext(0.5, -0.02, 'Hungary', horizontalalignment='center', fontsize=12)
352
390
plt.show()
@@ -398,7 +436,15 @@ lab = ['Wholesale Price Index', '1/Cents per Polish Mark']
398
436
399
437
# create plot
400
438
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
401
- ax1 = create_plot(p_seq, e_seq, df_Pol.index, lab, ax)
439
+ ax1 = create_pe_plot(p_seq, e_seq, df_Pol.index, lab, ax)
440
+
441
+ plt.figtext(0.5, -0.02, 'Poland', horizontalalignment='center', fontsize=12)
442
+ plt.show()
443
+ ```
444
+
445
+ ``` {code-cell} ipython3
446
+ fig, ax = plt.subplots(figsize=[10,7], dpi=200)
447
+ _ = create_pr_plot(p_seq, df_Pol.index, ax)
402
448
403
449
plt.figtext(0.5, -0.02, 'Poland', horizontalalignment='center', fontsize=12)
404
450
plt.show()
@@ -423,7 +469,7 @@ lab = ['Price Index', '1/Cents per Mark']
423
469
424
470
# create plot
425
471
fig, ax = plt.subplots(figsize=[9,5], dpi=200)
426
- ax1 = create_plot (p_seq, e_seq, df_Germ.index, lab, ax)
472
+ ax1 = create_pe_plot (p_seq, e_seq, df_Germ.index, lab, ax)
427
473
428
474
plt.figtext(0.5, -0.06, 'Germany', horizontalalignment='center', fontsize=12)
429
475
plt.show()
@@ -441,7 +487,15 @@ lab = ['Price Index (Marks or converted to Marks)', '1/Cents per Mark (or Reichs
441
487
442
488
# create plot
443
489
fig, ax = plt.subplots(figsize=[10,7], dpi=200)
444
- ax1 = create_plot(p_seq, e_seq, df_Germ.index, lab, ax)
490
+ ax1 = create_pe_plot(p_seq, e_seq, df_Germ.index, lab, ax)
491
+
492
+ plt.figtext(0.5, -0.02, 'Germany', horizontalalignment='center', fontsize=12)
493
+ plt.show()
494
+ ```
495
+
496
+ ``` {code-cell} ipython3
497
+ fig, ax = plt.subplots(figsize=[10,7], dpi=200)
498
+ _ = create_pr_plot(p_seq, df_Germ.index, ax)
445
499
446
500
plt.figtext(0.5, -0.02, 'Germany', horizontalalignment='center', fontsize=12)
447
501
plt.show()
0 commit comments