I figured out that I can rotate a Plot
by accessing an undocumented API:
import igraph as ig
g = ig.Graph.Bipartite([0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
[(0, 6), (1, 6), (2, 7), (3, 8), (4, 9), (5, 6)])
plot = ig.plot(g, layout=g.layout_bipartite(), vertex_label=list('ABCDEFwxyz'))
# -> plot is vertical
# access Layout object and call its rotate method
plot._objects[0][-1]["layout"].rotate(90)
# -> plot is now horizontal!
Any chance we can expose this ability to manipulate the layout through a stable API? And maybe we can even make horizontal orientation the default for the bipartite layout?
I figured out that the following works:
lo = g.layout_bipartite()
lo.rotate(90)
plot = ig.plot(g, layout=lo, vertex_label=list('ABCDEFwxyz'))
The important thing is that the rotation has to happen in a separate step, because the .rotate
method returns None
.
Yes, indeed, the rotation happens “in place”, so to speak. You would find it more intuitive if you could concatenate the steps like g.layout_bipartite().rotate(90).mirror()
for example?
Do note that the functionality is documented here.
1 Like
You would find it more intuitive if you could concatenate the steps like g.layout_bipartite().rotate(90).mirror()
for example?
That’s what I tried initially, so yes, I suppose it would be more intuitive to be able to chain methods like that. Though I am familiar with the convention of returning None
for such in-place mutations of objects in Python.
Do note that the functionality is documented
Thanks, I found that eventually. It’s not linked to from the API reference for Plot
which is why I missed it at first.
thanks for the awesome information.
thanks my issue has been fixed.