# coding: utf-8
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
# first column is total number of people
# second column is percentage of the population
data = np.array([
6232552, 8.29],
5657791, 7.53],
5671435, 7.55],
6607043, 8.79],
8414497, 11.20],
8672654, 11.54],
6971924, 9.28],
5571018, 7.41],
4906749, 6.53],
4030481, 5.36],
3527408, 4.69],
2680119, 3.57],
1862907, 2.48],
1343731, 1.79],
1119968, 1.49],
913531, 1.22],
919539, 1.22]])
labels =
'0-4',
'5-9',
'10-14',
'15-19',
'20-24',
'25-29',
'30-34',
'35-39',
'40-44',
'45-49',
'50-54',
'55-59',
'60-64',
'65-69',
'70-74',
'75-79',
'80 and over'
# Prepare axis
fig = plt.figure(figsize=(9, 5))
ax = fig.add_subplot(111)
y_pos = np.arange(len(labels))
percentages = data[:, 1
ax.barh(y_pos, percentages, align='center')
plt.yticks(y_pos, labels)
plt.axis('tight')
plt.title('Iranian Demography 2011')
plt.xlabel('Percentage')
plt.savefig('iran-demography.svg', transparent=True)