-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbarplot_CELE.py
More file actions
55 lines (54 loc) · 1.48 KB
/
barplot_CELE.py
File metadata and controls
55 lines (54 loc) · 1.48 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
from operator import itemgetter
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sb
sb.set_context("poster")
plt.rcParams.update({"font.size": 24})
# europe pop taken from https://www.worldometers.info/world-population/europe-population/
# usa from Data/SmallData/ElectricityByNation/PopByCountry.csv
# year=2018
x = pd.read_csv("CELE_region_values.csv")
x.replace("europe", "Europe", inplace=True)
x.replace("north-america", "North America", inplace=True)
# x = x[x["region"] != "usa"]
x["popRatio"] = (x["populationCELE"] / x["population"]) * 100
x["oneInXyears"] = (1 / x["rate"]).astype(int)
x = x[x["popRatio"] > 0]
print(x)
palette = itemgetter(0, 3)(sb.color_palette())
_, axs = plt.subplots(1, 3, tight_layout=True, figsize=(22, 9))
sb.barplot(
x,
x="oneInXyears",
y="popRatio",
hue="region",
legend=False,
ax=axs[0],
palette=palette,
)
axs[0].set_xlabel("Storm recurrence [years]")
axs[0].set_ylabel("Population in CELE [%]")
sb.barplot(
x,
x="oneInXyears",
y="populationCELE",
hue="region",
legend=False,
ax=axs[1],
palette=palette,
)
axs[1].set_xlabel("Storm recurrence [years]")
axs[1].set_ylabel("Population in CELE [people]")
sb.barplot(
x,
x="oneInXyears",
y="totalGWloss",
hue="region",
legend="full",
ax=axs[2],
palette=palette,
)
axs[2].set_xlabel("Storm recurrence [years]")
axs[2].set_ylabel("Electricity loss [GW]")
plt.savefig("CELE_bar.eps", bbox_inches="tight", dpi=72)
# plt.show()