2

I have a problem with VisNetwork. I created a graph in R and each time when I click on the node and move it to other place, it comes back to where it was before. Is there any possibility to rearrange network manually? I'd like to move some nodes to the other place or to change the length of edges between some nodes, so that it would be more transparent.

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
Natalia
  • 375
  • 3
  • 11

1 Answers1

1

At least two possibilities :

Use vis.js to compute coordinate (default) and then after disable physics

require(visNetwork)
nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))
visNetwork(nodes, edges)  %>% 
  visEvents(stabilizationIterationsDone="function () {this.setOptions( { physics: false } );}")

Or Use igraph to compute coordinate. It's faster, and physics is disabled automatically

visNetwork(nodes, edges) %>% visIgraphLayout()

You can also set coordinate before render with x & y columns in nodes

bthieurmel
  • 524
  • 2
  • 3
  • 5
    Can you explain how to manually set the coordinates? I've created `x` and `y` values in `nodes` but it does not seem to follow them at all. – vashts85 Jul 14 '17 at 21:08
  • 3
    Can you add an example on how to achieve it? Would be super useful! :) – DaveTheAl Apr 05 '20 at 12:32
  • is it possible to achieve something like [this](https://stackoverflow.com/questions/65583493/vis-network-define-node-location) with igraph ?appreciate if you can provide an example – user5249203 Jan 05 '21 at 17:38
  • Greetings, could any of you set the coordinates manually? – MatCordTo May 26 '22 at 10:14