tags:

views:

149

answers:

1

It is very straight-forward to plot a tree using igraph in R

library(igraph)
plot(graph.tree(20, 2), layout=layout.reingold.tilford)

Is it possible to "turn the graph around", so that the root (node 0) is at the top of the plot? Or, alternatively, is it possible to put the root to middle left?

+1  A: 

The easiest way I know of is like this:

plot(graph.tree(20, 2), layout=layout.reingold.tilford, ylim=c(1,-1))

I don't know whether that's officially supported though.

Ken Williams
Just for reference: inspecting plot.igraph shows that this works because it rescales the layout by default. plot(..., rescale=FALSE) fails.
Karsten W.
Another option I just found out by searching the igraph mailing list would be to first call layout.reingold.tilford, transform the result (the second column), and then call plot.igraph.
Karsten W.