# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
plt.rcdefaults()
plt.rcParams['figure.figsize'] = 6, 4
grid_alpha = 0.25
width = 0.4
labels = ['China', 'Russia', 'Hungary', 'U.S.', 'Romania', 'Germany', 'Bulgaria', 'Iran', 'S. Korea']
labels_ISO = ['CHN', 'RUS', 'HUN', 'USA', 'ROU', 'DEU', 'BGR', 'IRN', 'KOR']
values = [19, 14+2, 6, 6, 5, 2+1, 1, 1, 1]
# USSR/Russia W.Germ/E.Germ
xticks = [x for x in range(0,len(labels),1)]
fig, ax = plt.subplots()
ax.yaxis.grid(linestyle='-', linewidth=1, alpha=grid_alpha, color='k')
ax.set_ylabel('Frequency')
ax.set_title('Mathematical Olympiad:\n'+'Highest team score winner frequency',fontsize=11.5)
ax.set_xticks(xticks)
ax.set_xticklabels(labels,rotation=45)
ax.yaxis.set_major_locator(MultipleLocator(5))
ax.yaxis.set_major_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_minor_locator(MultipleLocator(1))
ax.bar(xticks, values, width)
fig.tight_layout()
fig.savefig('International_Mathematical_Olympiad_highest_team_score_bar_chart.svg')