Arrows position in schemdraw flowchart

441 Views Asked by At

I am new to Python, and schemdraw. I am trying to connect the "end" of the flowchart with "activity 6".

However the arrow comes out from the side (red arrow, and wrong position), and I'm trying to get it to come out (black arrow, correct position) from the down of the box.

Could someone help me?

pip install schemdraw
import schemdraw
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(''))

    # May be here!!!
    d += flow.Arrow().down()
    d += flow.Start(w=8, h=2).anchor('W').label('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'))


enter image description here

Thanks in advance!

1

There are 1 best solutions below

0
htun htike On

You can use this code.

 d += flow.Arrow().down().at(act6.S)
 d +=flow.Terminal(w=6, h=2).label('End')