-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplots.py
More file actions
59 lines (36 loc) · 1.59 KB
/
Copy pathmatplots.py
File metadata and controls
59 lines (36 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# from myPlotter import myPlotter
data = pd.read_csv('countries.csv')
greece = data[data.country == 'Greece']
germany = data[data.country == 'Germany']
france = data[data.country == 'France']
fig, ax = plt.subplots(2, 2)
ax[0, 0].set_title('Population growth comparison.')
ax[0, 0].plot(greece.year, greece.population / 10**6, label='Greece')
ax[0, 0].plot(germany.year, germany.population / 10**6, label='Germany')
ax[0, 0].plot(france.year, france.population / 10**6, label='France')
ax[0, 0].legend()
ax[0, 0].set_xlabel('Year')
ax[0, 0].set_ylabel('Population (in millions)')
ax[0, 1].set_title('Precentage of Total population per Country.')
totalPopulation = int(greece.population.tail(1)) + int(germany.population.tail(1)) + int(france.population.tail(1))
greekPrecentage = (int(greece.population.tail(1)) * 100 / totalPopulation)
germanyPrecentage = (int(germany.population.tail(1)) * 100 / totalPopulation)
francePrecentage = (int(france.population.tail(1)) * 100 / totalPopulation)
labels = 'Greece', 'Germany', 'France'
sizes = [greekPrecentage, germanyPrecentage, francePrecentage]
ax[0, 1].pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)
ax[0, 1].axis('equal')
###########
# CHART 3 #
###########
ax[1, 0].set_title('Population of Greece 1987-2007.')
xPos = np.arange(len(greece.year.tail()))
ax[1, 0].bar(xPos, greece.population.tail()/10**6, align='center', width=0.35)
ax[1, 0].set_xticks(xPos)
ax[1, 0].set_xticklabels(greece.year.tail())
ax[1, 0].set_ylim(top=12)
ax[1, 1].set_title('Chart 4.')
plt.show()