Constant layout orientation in igraph
1
1
Entering edit mode
8.2 years ago

I am drwaning graphs in igraph using the "layout_with_dh" layout, but everytime i generate the graph the orientation is changed. Is there a way to keep the same orientation of the graph as i would be looking at the graph for different timepoints so I want them to look the same.

RNA-Seq R • 6.0k views
ADD COMMENT
2
Entering edit mode

Try setting the random number generator seed with set.seed(). For example:

library(igraph)
g <- barabasi.game(10)
set.seed(123)
plot(g, layout = layout_with_dh)
ADD REPLY
1
Entering edit mode
8.2 years ago

The best approach for dynamic graphs is to fix the node positions after running one of the layout algorithms on one instance of the graph. You can get the coordinates from the corresponding igraph layout function, e.g.:

coords <- layout.davidson.harel(g)
plot(g, layout = coords)

This means you can also manually tweak the coordinates to your liking.

ADD COMMENT

Login before adding your answer.

Traffic: 1715 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6