jcarlos
jcarlos

Reputation: 435

Layout layout.reingold.tilford issue ploting a tree in R

I´m trying to plot a Tree using igraph and started from very simple examples available on the web, one of them is

library(igraph)
el <- matrix( c("root", "y", "root", "x", "x", "a", "x", "b"), nc=2, byrow=TRUE)
g13 <- graph.edgelist(el)
co <- layout.reingold.tilford(g13, flip.y=TRUE)
plot(g13, layout=co)

The issue is I get all vertices on the same line, the root at left and the rest to right of it, as shown:

enter image description here

I tried other variations like

plot(g13, layout=layout.reingold.tilford)

and the results were the same.

What am I doing wrong?

Regards

Upvotes: 1

Views: 1906

Answers (1)

digEmAll
digEmAll

Reputation: 57210

It seems necessary to specify the root node:

co <- layout.reingold.tilford(g13, params=list(root=1))
plot(g13, layout=co)

enter image description here

Upvotes: 3

Related Questions