Skip to content

Position feature does not work as intended in flow drawing  #4

@oroojlooy

Description

@oroojlooy

Any idea why nodes 3, 4, and 5 are not in the same x-axis position as nodes 0, 1, and 2 are?

import schemdraw
import schemdraw.elements as elm
from schemdraw import flow

edge = [(0,2), (1, 2), (2, 3), (3, 4), (3, 5)]
x_order = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3, 5: 3}
y_order = {0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 1}

drawing = {}
drawing[net] = schemdraw.Drawing()

drawing[net].config(fontsize=12)
delta = 4

nodes = []
node_dict = {}
position = {}

for e in edge:
    if e[0] not in nodes:
        nodes += [e[0]]
        pos = ((x_order[e[0]])*3, (y_order[e[0]])*3)
        position[e[0]] = pos
        node_dict[e[0]] = flow.Circle(r=1).at(pos).label('$S_{}$'.format(e[0]))
        drawing[net] += (node_dict[e[0]])
    if e[1] not in nodes:
        nodes += [e[1]]
        pos = ((x_order[e[1]])*3, (y_order[e[1]])*3)
        position[e[1]] = pos
        node_dict[e[1]] = flow.Circle(r=1).at(pos).label('$S_{}$'.format(e[1]))
        drawing[net] += (node_dict[e[1]])
    drawing[net] += elm.Arrow(arrow='->').at(node_dict[e[0]].E).to(node_dict[e[1]].W).label('0')

drawing[net].draw()

The output figure is available at the following link:
https://stackoverflow.com/questions/73227392/schemdraw-does-not-draw-flow-according-to-the-provided-position

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions