diff --git a/Fig3.zip b/Fig3.zip new file mode 100644 index 0000000..8de10e7 Binary files /dev/null and b/Fig3.zip differ diff --git a/change_new_fig.py b/change_new_fig.py new file mode 100644 index 0000000..db4729d --- /dev/null +++ b/change_new_fig.py @@ -0,0 +1,62 @@ +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() diff --git a/env_data.xlsx b/env_data.xlsx index 44e3e57..e171670 100644 Binary files a/env_data.xlsx and b/env_data.xlsx differ