briatte / ggnet

Network visualization with ggplot2
https://briatte.github.io/ggnet/
194 stars 33 forks source link

Node placement #16

Closed vikasrawal closed 8 years ago

vikasrawal commented 8 years ago

Is there a way to pre-specify placement of nodes? I would like to place one node at the center, and all the remaining nodes around it in a circle, and would like them to be placed in a pre-specified order.

briatte commented 8 years ago

Yes, that's doable.

You will need to write up the coordinates placement matrix yourself. The matrix should be of the form

               [,1]      [,2]
 [1,]  0.000000e+00  1.000000
 [2,]  5.877853e-01  0.809017
 [3,]  9.510565e-01  0.309017
etc.

Then, simply pass that matrix to the mode argument, and ggnet or ggnet2 will use it to place the nodes. Have a look at the documentation of the mode argument in either ggnet or ggnet2 for further details.

I dont know my trigonometry well enough to give a full example, but now you know how to place the nodes manually :)

Hope this helps!