# coding: utf-8
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
imf_data = np.array([
[1980, 1.272 ],
[1981, 0.110 ],
[1982, -0.788],
[1983, 1.555 ],
[1984, 2.826 ],
[1985, 2.192 ],
[1986, 2.417 ],
[1987, 1.469 ],
[1988, 3.736 ],
[1989, 3.913 ],
[1990, 5.723 ],
[1991, 5.011 ],
[1992, 1.508 ],
[1993, -0.979],
[1994, 2.527 ],
[1995, 1.815 ],
[1996, 0.859 ],
[1997, 1.902 ],
[1998, 1.776 ],
[1999, 1.845 ],
[2000, 3.194 ],
[2001, 1.843 ],
[2002, 0.016 ],
[2003, -0.733],
[2004, 0.703 ],
[2005, 0.878 ],
[2006, 3.879 ],
[2007, 3.383 ],
[2008, 0.805 ],
[2009, -5.565],
[2010, 3.945 ],
[2011, 3.718 ],
[2012, 0.613 ],
[2013, 0.406 ],
[2014, 1.580 ]])
imf_estimates = np.array([
[2014, 1.580 ],
[2015, 1.509 ],
[2016, 1.573 ],
[2017, 1.510 ],
[2018, 1.295 ],
[2019, 1.295 ],
[2020, 1.269 ]])
def running_mean(x, N):
window = np.ones(N) / N
mean = np.convolve(x, window)
return mean[(N-1):]
# Prepare axis
fig = plt.figure(figsize=(8, 4))
ax = fig.add_subplot(111)
# Plot data
years = imf_data[:, 0]
growth = imf_data[:, 1]
growth_mean = running_mean(growth, 5)
years_est = imf_estimates[:, 0]
growth_est = imf_estimates[:, 1]
ax.plot(years, growth, 'k')
ax.plot(years, growth_mean, 'r')
ax.plot(years_est, growth_est, 'k--')
plt.grid()
plt.title(u'Wirtschaftswachstum Deutschlands 1980-2020')
plt.xlabel('Jahr')
plt.ylabel(u'Reales jährliches prozentuales\n Wirtschaftswachstum')
plt.savefig('wirtschaftswachstum-deutschland.svg', transparent=True)