From 561c59fbd45d6a28ab8c7a678e82affd45bc999c Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 22 Jun 2026 16:37:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(scatter=5Flegend):=20=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E7=89=88=E6=95=A3=E7=82=B9=E5=9B=BE=20legend=20=E7=A7=BB?= =?UTF-8?q?=E5=87=BA=E7=94=BB=E5=B8=83=E9=98=B2=E6=AD=A2=E9=81=AE=E6=8C=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/postprocessing/visualization_reports.py plot_scatter_true_vs_pred: ax.legend 加 bbox_to_anchor=(1.02, 1) + borderaxespad=0,将图例移到画布右侧外部。 已有 plt.tight_layout() 与 plt.savefig(..., bbox_inches='tight') 自动处理裁剪。 Why: loc='upper left' 时图例位于散点区左上角,训练/测试点集中时易被遮挡。 仅改基础版(plot_scatter_true_vs_pred),增强版 sctter_batch.py 是 gridspec 4x4 子图布局,硬套 bbox_to_anchor 会破坏右侧 ax_hist_y 子图,保留原样。 --- src/postprocessing/visualization_reports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postprocessing/visualization_reports.py b/src/postprocessing/visualization_reports.py index 75f354f..0071ed5 100644 --- a/src/postprocessing/visualization_reports.py +++ b/src/postprocessing/visualization_reports.py @@ -133,7 +133,7 @@ class WaterQualityVisualization: ax.set_xlabel(f'真实值 ({target_name})', fontsize=14, fontweight='bold') ax.set_ylabel(f'预测值 ({target_name})', fontsize=14, fontweight='bold') ax.set_title(f'{target_name} - 真实值 vs 预测值', fontsize=16, fontweight='bold') - ax.legend(loc='upper left', fontsize=11) + ax.legend(loc='upper left', fontsize=11, bbox_to_anchor=(1.02, 1), borderaxespad=0) ax.grid(True, alpha=0.3) # 添加指标文本框