63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
|
import numpy as np
|
||
|
import pandas as pd
|
||
|
import matplotlib.pyplot as plt
|
||
|
from datetime import datetime
|
||
|
|
||
|
num_time_step = 201
|
||
|
num_iter = 10
|
||
|
|
||
|
env_data = pd.DataFrame(pd.read_excel('env_data.xlsx', engine='openpyxl', sheet_name=0))
|
||
|
|
||
|
assert env_data.shape[0] == num_iter * (num_time_step + 1), f"{env_data.shape[0]}, {num_iter * (num_time_step + 1)}"
|
||
|
|
||
|
lst_df = []
|
||
|
for i in range(num_iter):
|
||
|
df_tmp = env_data.iloc[i * (num_time_step + 1): (i + 1) * (num_time_step + 1), 1:]
|
||
|
lst_df.append(df_tmp)
|
||
|
|
||
|
lst_column = lst_df[0].columns
|
||
|
# print(lst_column)
|
||
|
# lst_column = [lst_column[2], lst_column[0]]
|
||
|
|
||
|
dct_y = {
|
||
|
'out_w_avg_salary': 'Avg. salary of workers',
|
||
|
'out_w_gini_salary': "Gini index of workers' salaries (unit: 1)",
|
||
|
'out_f_avg_profit': "Avg. profit of firms",
|
||
|
'out_f_avg_yield': "Avg. yield of firms (unit: 1)",
|
||
|
'out_f_gini_profit': "Gini index of firms' profit (unit: 1)",
|
||
|
'out_w_percent_hired': "% hired workers (unit: %)"
|
||
|
}
|
||
|
|
||
|
dct_file_name = {
|
||
|
'out_w_avg_salary': 'd',
|
||
|
'out_w_gini_salary': "e",
|
||
|
'out_f_avg_profit': "a",
|
||
|
'out_f_avg_yield': "c",
|
||
|
'out_f_gini_profit': "b",
|
||
|
'out_w_percent_hired': "f"
|
||
|
}
|
||
|
|
||
|
for str_col in lst_column:
|
||
|
x = np.arange(num_time_step+1)
|
||
|
for df in lst_df:
|
||
|
y = np.array(df[str_col]).flatten()
|
||
|
if str_col == 'out_f_avg_profit':
|
||
|
y /= 10000000000
|
||
|
plt.ylabel(dct_y[str_col] + r' (unit: $1 \times 10^{10}$ CNY)')
|
||
|
elif str_col == 'out_w_avg_salary':
|
||
|
y /= 1000000000
|
||
|
plt.ylabel(dct_y[str_col] + r' (unit: $1 \times 10^{9}$ CNY)')
|
||
|
elif str_col == 'out_w_percent_hired':
|
||
|
from matplotlib.ticker import PercentFormatter
|
||
|
plt.gca().yaxis.set_major_formatter(PercentFormatter(1, decimals=0))
|
||
|
plt.ylabel(dct_y[str_col])
|
||
|
else:
|
||
|
plt.ylabel(dct_y[str_col])
|
||
|
plt.xlabel('Time step')
|
||
|
plt.plot(x, y)
|
||
|
# plt.show()
|
||
|
# plt.close()
|
||
|
# plt.savefig(f"{str_col}-{datetime.today().strftime('%Y-%m-%d')}.pdf", bbox_inches="tight")
|
||
|
plt.savefig(f"Fig3{dct_file_name[str_col]}.pdf", bbox_inches="tight")
|
||
|
plt.close()
|