You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Schemdraw流程图箭头位置问题:End框与Activity 6的正确连接

解决Schemdraw流程图箭头起点错误问题

你的代码存在两个关键问题导致箭头位置错误:一是未明确指定箭头起点为activity 6的底部;二是缺失flow模块的导入,代码本身无法运行。以下是修正后的完整代码:

pip install schemdraw
import schemdraw
from schemdraw import flow  # 补充导入flow模块
import schemdraw.elements as elm

with schemdraw.Drawing() as d:
    d.config(fontsize=14)
    d += (b := flow.Start(w=6, h=2).label('Start'))
    d += flow.Arrow().down(d.unit/2)
    
    d += (step1 := flow.Box(w=8, h=2).label('Thing 1').fill(''))
    d += flow.Arrow().down(d.unit/2)
    d += (step2 := flow.Box(w=8, h=2).label('Thing 2').fill(''))
    d += flow.Arrow().down(d.unit/2)
    d += (step3 := flow.Box(w=8, h=2).label('Thing 3').fill(''))
    
    d += flow.Arrow().down(d.unit/2)
    d += (step4 := flow.Box(w=8, h=2).label('Thing 4').fill(''))
    d += flow.Arrow().down(d.unit/2)
    d += (step5 := flow.Box(w=8, h=2).label('Thing 5').fill(''))
    d += flow.Arrow().down(d.unit/2)
    d += (step6 := flow.Box(w=8, h=2).label('Thing 6').fill(''))
    
   
    # Activities
    d += flow.Arrow().right(d.unit/2).at(step1.E)
    d += (act1 := flow.Box(w=8, h=2).anchor('W').label('activity 1').fill(''))
    
    d += flow.Arrow().right(d.unit/2).at(step2.E)
    d += (act2 := flow.Box(w=8, h=2).anchor('W').label('activity 2').fill(''))

    d += flow.Arrow().right(d.unit/2).at(step3.E)
    d += (act3 := flow.Box(w=8, h=2).anchor('W').label('activity 3').fill(''))
 
    d += flow.Arrow().right(d.unit/2).at(step4.E)
    d += (act4 := flow.Box(w=8, h=2).anchor('W').label('activity 4').fill(''))
    
    d += flow.Arrow().right(d.unit/2).at(step5.E)
    d += (act5 := flow.Box(w=8, h=2).anchor('W').label('activity 5').fill(''))

    d += flow.Arrow().right(d.unit/2).at(step6.E)
    d += (act6 := flow.Box(w=8, h=2).anchor('W').label('activity 6').fill(''))

    # 修正后的End框连接代码
    d += flow.Arrow().down(d.unit/2).at(act6.S)  # 从activity6底部向下绘制箭头
    d += (end_box := flow.Start(w=8, h=2).anchor('N').label('End'))  # End框顶部对接箭头
 
    d += (phase1 := elm.EncircleBox([step1, step2, step3, act1, act2, act3], padx=.8).linestyle('--').linewidth(2).color('red'))
    d += (phase2 := elm.EncircleBox([step4, step5, act4, act5], padx=.8).linestyle('--').linewidth(2).color('blue'))
    d += (phase3 := elm.EncircleBox([step6, act6], padx=.8).linestyle('--').linewidth(2).color('green'))

关键修改说明

  • 补充from schemdraw import flow:原代码未导入flow模块,会导致运行报错
  • .at(act6.S):将箭头起点定位到activity 6框的底部中心锚点(S代表South)
  • .anchor('N'):将End框的顶部中心锚点(N代表North)作为箭头终点,确保箭头从activity6底部垂直连接到End框顶部

内容的提问来源于stack exchange,提问作者Kirds

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 11:36:14