Skip to content

[pyos][visualization] Reciprocal directed edges overlap #474

Open

Description

@szhorvat

When plotting a graph/matrix, reciprocal directed edges overlap. The result is that only the weight of one of them is visible, which is confusing. I believe NetworkX does support curved edges, which could be a solution. However, generally, visualization does not seem to be a priority for NetworkX, so perhaps it's not the best idea to rely on it in the long term.

M = gb.Matrix.from_edgelist([(0,1,10),(1,0,20)], nrows=2, ncols=2)
gb.viz.draw(M)
image

Both weights, 10 and 20, should be visible, and it should be clear which belongs to which edge.

I think this is important since draw() visualizes matrices specifically as directed graphs, with no undirected option being present.

Part of: pyOpenSci/software-submission#81

Activity

  1. eriknw commented on Jun 26, 2023

    @eriknw
    Member

    Yeah, this isn't good. This version of draw was part of the initial PoC that @jim22k created years ago. We do plan to give vizualization a revamp and to show examples by including notebooks in the docs (#407), b/c viz is great for user applications and make great examples.

    It might be nifty to be able to use netgraph or graph-tool (or ...) for viz.

    I think @paul-tqh-nguyen may be interested in looking into visualization

  2. szhorvat commented on Jun 26, 2023

    @szhorvat
    Author

    In case you're considering multiple viz backends, igraph does have good supports for both self-loops and multi-edges, and how has a matplotlib back-end.

  3. eriknw commented on Jun 29, 2023

    @eriknw
    Member

    Thanks for letting us know about viz in igraph!

    After a quick scan of examples, it's not clear to me how viz from igraph would be able to handle showing the edge attributes of reciprocal edges any better: https://python.igraph.org/en/latest/tutorials/index.html

  4. szhorvat commented on Jun 29, 2023

    @szhorvat
    Author

    I'm sorry about that, it seems that contrary to my memory, multi-edge handling is not yet implemented with the matplotlib backend. It does work with the Cairo backend.

  5. szhorvat commented on Jun 30, 2023

    @szhorvat
    Author

    @eriknw I need to correct myself again. It seems that multigraph plotting in igraph is broken in the development version, but it's working fine in the released version. Python is not my main language, so I was a bit confused.

    To be clear: Yes, multigraph plotting works fine in igraph with either the Cairo or matplotlib backends.

    Example:

    import igraph as ig
    import matplotlib.pyplot as plt
    
    g = ig.Graph([(0,1), (1,0), (1,2), (2,0)], directed=True)
    
    import matplotlib.pyplot as plt
    fig, ax= plt.subplots()
    ig.plot(g, edge_label=['a','b','c','d'], target=ax)
    
    image
  6. eriknw commented on Jul 11, 2023

    @eriknw
    Member

    Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions