I would like to optimise the positions of the first node set in a two-mode graph based on the positions of a first node set. I saw in the description of
layout_with_fr() that positions of egos and as I understood also of several nodes can be fixed. The following example shows this using lon lat values for 26 nodes of the first node set and
-inf for 26 nodes of the second node set.
# sample graph and transform to two-mode network g <- sample_pa(26, m=2) tm<-get.adjacency(g, names=FALSE) g <- graph_from_incidence_matrix(as.matrix(tm, time = max(events$time))) # lon lat data for the first node-set of the two-mode network lon <- c(8.156847,9.416345,9.368596,7.625363,7.702396,7.615194,7.073961,6.133073,9.06578,9.628154,7.156132,8.110061,6.780079,8.405384,8.24331,9.275258,8.591709,7.639228,8.756584,9.092979,8.808903,8.628586,6.657902,7.604754, 8.537324, 8.655167) lat <-c(47.40973,47.31729,47.36624,46.82192,47.45168,47.56484,46.71842,46.22047,46.9811,46.65624,47.3507,47.06778,46.99553,46.92681,46.85235,47.23359,47.71354,47.30422,47.06192,47.56883,46.29559,46.77191,46.57009,46.20956,47.1573,47.41282) # limits as in the example of ?layout_with_fr() minC <- rep(-Inf, vcount(g)) maxC <- rep(Inf, vcount(g)) minC[1:26] <- lon maxC[1:26] <- lat set.seed(1) co <- layout_with_fr(g, minx=minC, maxx=minC, miny=maxC, maxy=maxC) co[1,]
-Inf values which I get because I changed the option in
minx=minC, maxx=maxC,miny=minC, maxy=maxC to
minx=minC, maxx=minC,miny=maxC, maxy=maxC. How can I get this to work so that layout_with_fr optimises the positions conditional on lon lat values?
I would like to run after:
plot(g, layout=co, vertex.size=30, edge.arrow.size=0.2, vertex.label="", rescale=FALSE, xlim=range(co[,1]), ylim=range(co[,2]), vertex.label.dist=0, vertex.label.color="red", vertex.color = ifelse(V(g)$type == F, "red", "blue"))