Igraph fixed node coordinate location

I found this answer really helpful. This helps me display the networks / graphs and select the coordinates for the nodes on the graph.

However, the layout drags the coordinates from -1 to 1. At first I tried to figure out how this happens, but cannot. Does it do something like this?

(coordinate - mean(coordinates))/(coordinate + mean(coordinates)

Secondly, is there a way to keep the original coordinates? I would like to use the axes with the graph and therefore would prefer that there is no scaling of everything.

+5
source share
2 answers

The answer to your first question is in the function source code plot.igraph; type plot.igraphR at the command prompt to get the full source code. There is a part that says:

layout <- layout.norm(layout, -1, 1, -1, 1)

layout.norm - igraph, ; layout.norm, , .

; rescale=F plot, igraph plot.igraph, layout.norm, . xlim ylim, , X Y.

+9
  set.seed(111)
  ig <- graph_from_data_frame(as.data.frame(matrix(sample(letters,40,rep=TRUE),nc=2)))
  set.seed(123)
  ig.layout <- layout.fruchterman.reingold(ig)
  rownames(ig.layout) <- V(ig)$name
  par(bg="white",mar=c(0,0,0,0),oma=c(0,0,0,0))
  plot.igraph(ig,layout=ig.layout,vertex.color=adjustcolor("gray",alpha.f=0.5),rescale=FALSE,xlim=c(4,11),ylim=c(4,11))
  set.seed(321)
  ig.sub <- subgraph(ig,sample(V(ig)$name,5))
  plot.igraph(ig.sub,layout=ig.layout[V(ig.sub)$name,],add=TRUE,vertex.color=adjustcolor("orange",alpha.f=0.5),rescale=FALSE)

, node .

enter image description here

0

All Articles