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

Edge does not always reflect a label and position it offset #920

Open
rat-h opened this issue Jul 20, 2023 · 0 comments
Open

Edge does not always reflect a label and position it offset #920

rat-h opened this issue Jul 20, 2023 · 0 comments

Comments

@rat-h
Copy link

rat-h commented Jul 20, 2023

I want to use diagrams to automatically draw models of a brain network. I need to cluster different parts and label connections with connection weight and delay. However, edges not always show labels and if they show the position of the label is somewhat off.

Here a minimal

from diagrams import Diagram, Cluster, Edge
from diagrams.custom import Custom



nodes=['P', 'I', 'T', 'R']
connections=[
    ['T', 'P', 0.07215613318258902 , 3.000411809536968],
    ['P', 'T', 0.04542521977383042 , 3.000411809536968],
    ['P', 'R', 0.028688428150340634, 3.000411809536968],
    ['P', 'I', 0.20226356207694524 , 4.606920945687344],
    ['I', 'P', 6.781459088887569   , 0.9380132322853566],
    ['P', 'P', 0.003704263180325445, -0.1],
    ['R', 'T', 0.3439813519108478  , 5.132116246577708]
]
gnodes={}
with Diagram(f"Model ", 
    show=False, filename=f"diagramtest", 
    outformat=["jpg", "png", "svg"],
    direction="LR"):
    with Cluster("Cortex",direction="TB"):
        for n in list('PIE'):
            if n in nodes:
                gnodes[n] = Custom(n,f'tmp/{n}.png',imagescale="false")
    with Cluster("Thalamus",direction="TB"):
        for n in list('RT'):
            if n in nodes:
                gnodes[n] = Custom(n,f'tmp/{n}.png',imagescale="false")
    for f,t,w,d in connections:
        gnodes[f] >> Edge(label=f'{w:0.3g} {d:0.3g}') >> gnodes[t]

diagramtest

On the diagram connection from P to R and from P to itself doesnot have lables. The over labels are offset quite alot.

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