# This is a Python-script to generate Scalable Vector Graphics (SVG): Wind_power_generation_in_China_TWh.SVG
# The resulting plot shows a bar-chart of the Wind power generation in China in TWh.
# The data are taken from https://en.wikipedia.org/wiki/Wind_power_in_China.
# Reference (2018): https://chinaenergyportal.org/en/2018-electricity-other-energy-statistics/
#
# To regenerate the bar-chart in the future with new data copy this Python-script and save it on
# your local computer with a filename ending with .py e.g. Wind_power_generation_in_China_TWh.py.
# Extend bar_heights, bar_labels and bar_x_positions with new data and run the script.
# Copy the extended code manually
#
# author: MTheiler, 2019-05-05 and 2024-01-15
# update with years 2019, 2020, 2021
import matplotlib.pyplot as plt
# label of y-axis
plt.ylabel('TWh')
# start with year 2005 and show only every second year on the x-axis
#bar_heights = [1260, 2599, 5912,12200,16000,31100,62700,75000,91424,114763,129700,149000,163670,184260]
bar_heights = [1.927, 3.675, 5.710, 14.800, 26.900, 44.622, 74.100, 103.000, 134.900, 153.400, 186.300, 241.000, 305.700, 366.000, 405.700, 466.500, 655.600]
bar_labels = [' ','2006',' ','2008',' ','2010',' ','2012',' ','2014',' ','2016',' ','2018',' ','2020',' ' ]
bar_x_positions = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
# plot the bar chart color = 'darkred'
plt.bar(bar_x_positions, bar_heights )
plt.xticks(bar_x_positions, bar_labels)
# save the generated svg
plt.savefig('Wind power generation in China TWh.svg', format='svg')
plt.show()