import matplotlib.pyplot as plt
import numpy as np
# Wind power installed capacity and generation in Finland
# data from https://fi.wikipedia.org/wiki/Tuulivoima_Suomessa
data=[
# show_X, year, installed (MW), Production (GWh)
#[' ',1992 , 1 , 2 ] ,
#[' ',1993 , 5 , 4 ] ,
#[' ',1994 , 5 , 5 ] ,
#['x',1995 , 6 , 11 ] ,
#[' ',1996 , 7 , 11 ] ,
#[' ',1997 , 12 , 17 ] ,
#[' ',1998 , 17 , 24 ] ,
#[' ',1999 , 38 , 49 ] ,
#['x',2000 , 38 , 77 ] ,
#[' ',2001 , 39 , 70 ] ,
#[' ',2002 , 43 , 63 ] ,
#[' ',2003 , 52 , 92 ] ,
#[' ',2004 , 82 , 120 ] ,
['x',2005 , 79 , 168 ] ,
[' ',2006 , 86 , 153 ] ,
[' ',2007 , 109 , 188 ] ,
[' ',2008 , 142 , 261 ] ,
[' ',2009 , 146 , 277 ] ,
['x',2010 , 196 , 294 ] ,
[' ',2011 , 198 , 481 ] ,
[' ',2012 , 257 , 494 ] ,
[' ',2013 , 447 , 777 ] ,
[' ',2014 , 627 , 1112 ] ,
['x',2015 , 1005 , 2300 ] ,
[' ',2016 , 1533 , 3100 ] ,
[' ',2017 , 2044 , 4800 ] ,
[' ',2018 , 2041 , 5857 ] ,
[' ',2019 , 2284 , 5987 ] ,
['x',2020 , 2586 , 7788 ] ,
[' ',2021 , 3257 , 8061 ] ,
[' ',2022 , 5677 , 11500 ] ,
[' ',2023 , 6944 , 14400 ]
]
# please update in future.
show_yesno = np.array([row[0] for row in data])
all_years = np.array([row[1] for row in data])
bar_labels = []
# show axis-labels only the years marked with 'x'
for i, yesNo in enumerate(show_yesno):
if (yesNo == 'x'):
bar_labels.append(all_years[i])
else:
bar_labels.append("")
data_installed = np.array([row[2] for row in data]) # installed
data_generated = np.array([row[3] for row in data]) # generated
fig = plt.figure()
ax1 = plt.gca()
ax2 = ax1.twinx()
width =0.3
ax1.bar(np.arange(len(data_installed))- width/2, data_installed, width=width)
ax2.bar([0], [0], label='installed capacity (MW)')
ax2.bar(np.arange(len(data_generated))+ width/2, data_generated, width=width, color='red', label='generation (GWh)')
plt.xticks(range(len(bar_labels)), bar_labels )
plt.title('Wind power installed capacity and generation in Finland')
ax1.set_ylabel('installed capacity (MW)')
ax2.set_ylabel('generation (GWh)')
ax1.set_xlabel("Source: https://fi.wikipedia.org/wiki/Tuulivoima_Suomessa", fontsize='xx-small')
plt.legend(loc='upper left', borderaxespad=1.5)
plt.tight_layout()
plt.savefig('Wind_power_installed_capacity_and_generation_in_Finland.svg')
plt.show()