This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Constant layout orientation in igraph

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

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)

1 answer

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.

Log in to answer this question.