-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.py
40 lines (29 loc) · 976 Bytes
/
boot.py
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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
csv = pd.read_csv("boot.csv")
print(csv)
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker as mticker
csv = csv.apply(lambda row: row / row.sum() if row.sum() > 0 else row, axis=1)
data = {}
for col in csv.columns:
data[col] = np.array(csv[col])
unit_of_time = np.arange(0, len(data[col]), 1)
fig, ax = plt.subplots()
print(unit_of_time)
print(data.values)
ax.stackplot(unit_of_time, data.values(),
labels=data.keys(), alpha=0.8)
ax.legend(loc='upper left', reverse=True)
ax.set_title('Proportion of exceptions per category')
ax.set_xlabel('Unit of time')
ax.set_ylabel('Cumulative percentage')
# add tick at every 200 million people
ax.yaxis.set_minor_locator(mticker.MultipleLocator(.2))
# Place legend outside the plot
ax.legend(loc="upper left", bbox_to_anchor=(1, 1))
# Adjust layout to make space for the legend
plt.tight_layout()
plt.show()