Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8871789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:04:45+00:00 2026-06-14T18:04:45+00:00

I’m trying to plot/sketch (matplotlib or other python library) a 2D network of a

  • 0

I’m trying to plot/sketch (matplotlib or other python library) a 2D network of a big distance matrix where distances would be the edges of the sketched network and the line and column its nodes.

DistMatrix =
[       'a',   'b',     'c',    'd'],
['a',   0,      0.3,    0.4,    0.7],
['b',   0.3,    0,      0.9,    0.2],
['c',   0.4,    0.9,    0,      0.1],
['d',   0.7,    0.2,    0.1,    0] ]

I’m searching to sketch/plot the 2d network from such (bigger: thousand of columns and lines) distance matrix: node ‘a’ is linked to node ‘b’ by an edge depth of 0.3, nodes ‘c’ and ‘d’ would be tied by an edge depth of 0.1.
What are the tools/libraries I can used (distance matrix can be converted into numpy matrix) to get the sketch/graphical projection of such network? (pandas, matplotlib, igraph,…?) and some leads to do that quickly (I would not define my self Tkinter function to do that 😉 ) ?
thanks for your incoming answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:04:46+00:00Added an answer on June 14, 2026 at 6:04 pm

    The graphviz program neato tries to respect edge lengths. doug shows a way to harness neato using networkx like this:

    import networkx as nx
    import numpy as np
    import string
    
    dt = [('len', float)]
    A = np.array([(0, 0.3, 0.4, 0.7),
                   (0.3, 0, 0.9, 0.2),
                   (0.4, 0.9, 0, 0.1),
                   (0.7, 0.2, 0.1, 0)
                   ])*10
    A = A.view(dt)
    
    G = nx.from_numpy_matrix(A)
    G = nx.relabel_nodes(G, dict(zip(range(len(G.nodes())),string.ascii_uppercase)))    
    
    G = nx.drawing.nx_agraph.to_agraph(G)
    
    G.node_attr.update(color="red", style="filled")
    G.edge_attr.update(color="blue", width="2.0")
    
    G.draw('/tmp/out.png', format='png', prog='neato')
    

    yields

    enter image description here


    If you want to generate a dot file, you can do so using

    G.draw('/tmp/out.dot', format='dot', prog='neato')
    

    which yields

    strict graph {
        graph [bb="0,0,226.19,339.42"];
        node [color=red,
            label="\N",
            style=filled
        ];
        edge [color=blue,
            width=2.0
        ];
        B    [height=0.5,
            pos="27,157.41",
            width=0.75];
        D    [height=0.5,
            pos="69,303.6",
            width=0.75];
        B -- D   [len=2.0,
            pos="32.15,175.34 40.211,203.4 55.721,257.38 63.808,285.53"];
        A    [height=0.5,
            pos="199.19,18",
            width=0.75];
        B -- A   [len=3.0,
            pos="44.458,143.28 77.546,116.49 149.02,58.622 181.94,31.965"];
        C    [height=0.5,
            pos="140.12,321.42",
            width=0.75];
        B -- C   [len=9.0,
            pos="38.469,174.04 60.15,205.48 106.92,273.28 128.62,304.75"];
        D -- A   [len=7.0,
            pos="76.948,286.17 100.19,235.18 167.86,86.729 191.18,35.571"];
        D -- C   [len=1.0,
            pos="94.274,309.94 100.82,311.58 107.88,313.34 114.45,314.99"];
        A -- C   [len=4.0,
            pos="195.67,36.072 185.17,90.039 154.1,249.6 143.62,303.45"];
    }
    

    The png file could then be generated using the graphviz neato program:

    neato -Tpng -o /tmp/out.png /tmp/out.dot 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.