我是Python新手。
我正在创建这个流程图,我想在方框中添加一些标题(副标题1、2和3)。然而,我不知道如何做出这样的注解。
另外,我想扩大盒子的面积(红色,蓝色和绿色)。
拜托,有人能帮我吗?
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(''))
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'))
#d += elm.Label().label('Parallel',loc="top").color('red')

提前谢谢。
发布于 2022-04-19 01:13:57
您可以向EncircleBox元素添加标签,就像其他元素一样。但默认情况下,它将出现在框的上方,因此您需要指定位置和90度的旋转:
d += (phase1 := elm.EncircleBox([step1, step2, step3, act1, act2, act3], padx=2, pady=.5).linestyle('--').linewidth(2).color('red')
.label('Subtitle 1', loc='left', rotate=90))
d += (phase2 := elm.EncircleBox([step4, step5, act4, act5], padx=2, pady=.5).linestyle('--').linewidth(2).color('blue')
.label('Subtitle 2', loc='left', rotate=90))
d += (phase3 := elm.EncircleBox([step6, act6], padx=2, pady=.5).linestyle('--').linewidth(2).color('green')
.label('Subtitle 3', loc='left', rotate=90))padx和pady参数使EncircleBoxes在x和y方向上变大。
https://stackoverflow.com/questions/71906464
复制相似问题