Skip to content

Conversation

@iosonofabio
Copy link
Member

This partially fixes #662 based on what observed in the tutorial for the workshop.

If you do:

import igraph as ig
 G = ig.Graph.Famous("Zachary")
G['layout'] = G.layout_fruchterman_reingold()
ig.plot(G)

The plotter does not know the graph already has a layout and will compute a new one. That means, if you plot multiple times you can get stochasticity if you don't reinitialize the RNG.

This PR introduces a few lines of code that check for a graph attribute "layout" and if present use it as a persistent layout.

Do you want me to write a test for this?

@iosonofabio iosonofabio added the plotting Issues related to plotting graphs in igraph in general label May 4, 2023
@iosonofabio iosonofabio marked this pull request as ready for review May 4, 2023 04:34
@ntamas
Copy link
Member

ntamas commented May 4, 2023

Yes, please add a test and then we can merge.

@iosonofabio iosonofabio merged commit c22e1d6 into igraph:main May 11, 2023
vtraag pushed a commit to vtraag/python-igraph that referenced this pull request Jun 30, 2023
Plotting: use graph layout attribute if found

---------

Co-authored-by: Tamás Nepusz <ntamas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plotting Issues related to plotting graphs in igraph in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mpl plotting: layout as property of graph

2 participants