I have found this answer really useful. It helps me plot network/graphs and select the coordinates for the nodes in the plot.
However, the layout rescales the coordinates to -1 to 1. First off I tried to find out how it does this but couldn't. does it do something like this??
(coordinate - mean(coordinates))/(coordinate + mean(coordinates)
Second is there a way to keep the original coordinates? I woudl like to plat axes with the graph and so would prefer not to have top rescale everything.
The answer to your first question is in the source code of the plot.igraph
function; type plot.igraph
in the R prompt to get the full source code. There is a part in there which says:
layout <- layout.norm(layout, -1, 1, -1, 1)
layout.norm
is another function of igraph
which does the magic for you; type layout.norm
to see how it works.
Now, the answer to the second question is really simple; just pass rescale=F
to the arguments of plot
, which makes igraph
skip the entire branch in plot.igraph
where layout.norm
is called, so it will work with your original coordinates. You can then use xlim
and ylim
as usual to set the limits of the X and Y axes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With