How to control the igraph plot layout with Fixed Positions?

前端 未结 2 1121
不知归路
不知归路 2020-12-13 10:40

I am trying to draw a network visualization to resemble a flow diagram. I\'m fairly close with the following code, but I have a couple questions:

  1. Is this the
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 11:02

    A less complicated method than the above if you want to assign the node locations yourself is to add columns labelled x and y in your datasheet with the x and y coordinates for the respective nodes in those columns. e.g.

    library('igraph')
    nodes <- c('a','b','c','d')
    x <- c(0,1,2,3)
    y <- c(0,1,2,3)
    from <- c('a','b','c')
    to <- c('b','c','d')
    NodeList <- data.frame(nodes, x ,y)
    EdgeList <- data.frame(from, to)
    a<- graph_from_data_frame(vertices = NodeList, d= EdgeList, directed = FALSE)
    plot(a)
    

提交回复
热议问题