Despite the relative popularity of neighborNets, I couldn't find any solutions to the following problem. In R, I'm trying to plot a neighborNet (created using package phangorn
, object class networx). The package uses igraph
for plotting static 2D graphs, so every time I re-plot the graph, the layout changes/rotates (default behaviour of igraph
, apparently). Now, if I were to plot an usual igraph, I'd just save the layout, and then keep re-using it:
fixed = layout.sphere(somegraph)
plot(somegraph, layout=fixed)
But this doesn't work for the current problem. The help file of plot.networx does refer to igraph and layout, but only in the 'See also' section. Creating a x-y coordinate matrix manually wouldn't work (as suggested here), the location of the node labels/tips of nodes is significant on a neighbornet. I tried
library("phangorn")
library("igraph")
mydist = dist(matrix(sample(100), ncol=10)) # example data
nnet = neighborNet(mydist)
fixed = layout.sphere(nnet) # error, Not a graph object
fixed = layout.sphere(as.igraph(nnet)) # doesn't work properly, mangled graph
So the question, how to get it working in the vein of
plot.networx(nnet, type="2D", layout = fixed) # ?