-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraficos_real1.py
38 lines (28 loc) · 1.43 KB
/
graficos_real1.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
import pandas as pd
import matplotlib.pyplot as plt
from data import groups_cols
colors = ['tab:blue', 'tab:orange', 'tab:green', 'tab:red']
def plotting(data, name='name'):
lbsl = [groups_cols.abm_dummies_show[l] for l in data.index.tolist()]
fig, ax = plt.subplots(figsize=(8, 6))
for i, each in enumerate(['POLICIES_buy', 'POLICIES_rent', 'POLICIES_wage', 'POLICIES_no_policy']):
for mr in data.index:
ax.scatter(mr, data.loc[mr, each], color=colors[i], alpha=.6, marker='o')
plt.vlines(x=range(len(lbsl)), ymin=0, ymax=1, colors='lightgrey', lw=.8, alpha=.5)
plt.xticks(range(len(lbsl)), lbsl, rotation='vertical', fontsize=9)
ax.legend(['Purchase', 'Rent vouchers', 'Monetary aid', 'no-policy baseline'],
edgecolor='white', loc='upper center', facecolor='white', framealpha=1)
plt.ylabel("Percentage of Metropolitan Regions' optimal cases per policy")
leg = ax.get_legend()
for i in range(len(colors)):
leg.legendHandles[i].set_color(colors[i])
plt.tight_layout()
plt.savefig(f'graph_real_sorted_{name}.png', dpi=300)
plt.show()
if __name__ == '__main__':
p = 'data/IQR.csv'
d = pd.read_csv(p, sep=';')
d.drop('Unnamed: 0', inplace=True, axis=1)
pivoted_d = pd.pivot(d, index='ACP', columns='pol', values='mean')
pivoted_d.sort_values(by='POLICIES_no_policy', ascending=False, inplace=True)
plotting(pivoted_d, name='POLICIES_no_policy')