- Added pipeline_converging_triangle.py for streamlined execution of detection, reporting, and chart generation. - Introduced triangle_config.py for centralized parameter management across scripts. - Updated plot_converging_triangles.py to utilize parameters from the new config file. - Revised report_converging_triangles.py to reflect dynamic detection window based on configuration. - Enhanced existing scripts for improved error handling and output consistency. - Added new documentation files for usage instructions and parameter configurations.
1.6 KiB
1.6 KiB
枢轴点绘图问题记录
日期:2026-01-22
主题:收敛三角形图表中枢轴点位置异常与修复
背景现象
在 outputs/converging_triangles/charts 生成的图表中,标注的枢轴点(用于连线的关键点)出现挤在一起、位置不正确的问题。
根因分析
fit_pivot_line() 返回的 selected_ph / selected_pl 是枢轴点数组中的索引,而非检测窗口的真实索引。
绘图时直接用 selected_ph 作为 high_win/low_win 的索引,导致标注位置偏移到窗口开头。
问题代码路径:
scripts/plot_converging_triangles.py- 相关逻辑:
selected_ph/selected_pl与ph_idx/pl_idx的索引映射
修复方式
将枢轴点索引转换为真实位置:
selected_ph_pos = ph_idx[selected_ph]
selected_pl_pos = pl_idx[selected_pl]
绘图时使用真实位置:
ax1.scatter(selected_ph_display, high_win[selected_ph_pos], ...)
ax1.scatter(selected_pl_display, low_win[selected_pl_pos], ...)
视觉优化
将枢轴点标注样式改为空心圆圈,避免遮挡价格曲线:
marker='o', facecolors='none', edgecolors='red/green', linewidths=1.5
更新文件
scripts/plot_converging_triangles.py- 修复枢轴点索引映射
- 空心圆圈样式
验证步骤
重新生成图表:
python scripts/plot_converging_triangles.py
验证要点:
- 红/绿空心圆应落在真实高点/低点位置
- 不再出现“所有枢轴点挤在一起”的情况
如需进一步增强可视化,可新增“显示所有枢轴点”的开关,用于诊断与验证。