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
相关产品推荐
相关产品推荐

