-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_seaborn.py
More file actions
61 lines (44 loc) · 1.63 KB
/
Copy pathfinal_seaborn.py
File metadata and controls
61 lines (44 loc) · 1.63 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
60
61
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import csv
#########################################
# Opening the excel and extracting data #
#########################################
data = pd.read_csv('countries.csv')
greece = data[data.country == 'Greece']
germany = data[data.country == 'Germany']
france = data[data.country == 'France']
#############
# Chart One #
#############
df = pd.concat([greece, germany, france], axis=0)
temp_data_one = {'country': df.country, 'year': df.year, 'population': df.population}
new_data_one = pd.DataFrame(df)
sns.set(style="whitegrid")
g = sns.catplot(x="year", y="population", hue="country", data=new_data_one, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("Population")
fig = plt.figure()
fig.add_subplot(111)
fig.add_subplot()
#############
# Chart Two #
#############
sns.set(style="whitegrid")
df = {'Greece': greece.population.tolist(), 'Germany': germany.population.tolist(), 'France': france.population.tolist()}
df_new = pd.DataFrame(data=df, index=greece.year.tolist())
plt.subplot(222)
plt.subplot(sns.lineplot(data=df_new, palette="tab10", linewidth=2.5))
###############
# Chart Three #
###############
sns.set()
df = pd.concat([greece, germany, france], axis=0)
temp_data = {'country': df.country, 'year': df.year, 'population': df.population}
new_data = pd.DataFrame(df)
palette_style = sns.cubehelix_palette(rot=-.2, as_cmap=True)
plt.subplot(212)
plt.subplot(sns.scatterplot(x="population", y="year", style="country", palette=palette_style, data=new_data))
plt.show()