From 8f46aa50c4e85e1193f283a110ad60819e41e381 Mon Sep 17 00:00:00 2001 From: jingboyitiji Date: Tue, 5 Aug 2025 17:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8A=A5=E5=91=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools.py | 11 ++++++++++- main_juxiting_yuedu.py | 5 +++-- main_juxiting_zhoudu.py | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/tools.py b/lib/tools.py index 1b6ee20..8569c22 100644 --- a/lib/tools.py +++ b/lib/tools.py @@ -780,6 +780,7 @@ def get_model_id_name_dict(global_config): ''' tb = 'v_tbl_predict_models' sql = f'select model_name,id from {tb} ' + global_config['db_mysql'].connect() modelsname = global_config['db_mysql'].execute_query(sql) model_id_name_dict = {row['id']: row['model_name'] for row in modelsname} global_config['logger'].info(f'模型id-name: {model_id_name_dict}') @@ -1123,7 +1124,7 @@ def plot_pp_predict_result(y_hat, global_config,wd='yuedu'): sns.lineplot(x=y['ds'], y=y['y'], color='blue', label='真实值', ax=ax) # date_str = pd.Timestamp(y_hat["ds"].iloc[0]).strftime('%Y-%m-%d') - ax.set_title(f'{global_config["end_time"]} PP期货八大维度 预测价格走势') + ax.set_title(f'{global_config["end_time"]} PP期货八大维度 预测价格走势', fontsize=24) ax.set_xlabel('日期') ax.set_ylabel('预测结果') ax.tick_params(axis='x', rotation=45) @@ -1147,6 +1148,10 @@ def plot_pp_predict_result(y_hat, global_config,wd='yuedu'): # 在图表下方添加表格 table = ax.table(cellText=data, colLabels=columns, loc='bottom', bbox=[0, -0.4, 1, 0.2],cellLoc='center') + # 设置表头为浅蓝色 + for (i, j), cell in table.get_celld().items(): + if i == 0: # 表头行 + cell.set_facecolor('lightblue') table.auto_set_font_size(False) table.set_fontsize(12) @@ -1161,6 +1166,10 @@ def plot_pp_predict_result(y_hat, global_config,wd='yuedu'): bbox=[0, -0.9, 1, 0.4], # [左, 下, 宽, 高],调整下边界(-0.7)和高度(0.5)控制表格位置 cellLoc='left' ) + # 设置表头为浅蓝色 + for (i, j), cell in table.get_celld().items(): + if i == 0: # 表头行 + cell.set_facecolor('lightblue') table.auto_set_font_size(False) # 关闭自动字体大小 table.set_fontsize(10) # 设置表格字体大小 table.scale(1.1, 1.5) # 调整表格缩放比例(宽度, 高度) diff --git a/main_juxiting_yuedu.py b/main_juxiting_yuedu.py index f4075fa..13a254f 100644 --- a/main_juxiting_yuedu.py +++ b/main_juxiting_yuedu.py @@ -477,7 +477,7 @@ def predict_main(): # sqlitedb, end_time=global_config['end_time'], is_fivemodels=global_config['is_fivemodels']) # logger.info('训练数据绘图end') - push_market_value() + # push_market_value() # sql_inset_predict(global_config) @@ -530,7 +530,8 @@ if __name__ == '__main__': # logger.info(f'预测失败:{e}') # continue - predict_main() + global_config['end_time'] = '2025-08-01' + predict_main() # push_market_value() # 图片报告 diff --git a/main_juxiting_zhoudu.py b/main_juxiting_zhoudu.py index 2714533..4504c84 100644 --- a/main_juxiting_zhoudu.py +++ b/main_juxiting_zhoudu.py @@ -512,7 +512,11 @@ if __name__ == '__main__': # logger.info(f'预测失败:{e}') # continue + + global_config['end_time'] = '2025-08-01' + global_config['db_mysql'].connect() predict_main() + # push_market_value() # sql_inset_predict(global_config)