Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oroojlooy opened this issue Aug 3, 2022 · 0 comments
Open

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

oroojlooy opened this issue Aug 3, 2022 · 0 comments

Comments

@oroojlooy
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant