igraph package in r: edge labels are overlapping

。_饼干妹妹 提交于 2019-12-21 09:33:01

问题


I am working with the igraph package in R to visualise network flows.

library(igraph)

# Example Data:
b <- c("countryA", "countryB", "countryC", "countryA", "countryC", "countryA")
c <- c("countryB", "countryC", "countryA", "countryB", "countryA", "countryB")
d<- c(100, 200, 200, 300, 400, 200)
e <- c(5,12,10,24,25,12)
mydata <- data.frame(b,c,d,e)
colnames(mydata) <- c("exporteur", "partner", "tradeflow", "price")

# Plot in igraph
mydata.igraph <- graph.data.frame(mydata)
E(mydata.igraph)$label <- mydata[,3]
plot(mydata.igraph)

As you can see, my edge labels (labels of the arrows) are overlapping. How to solve this?

Thanks in advance!


回答1:


This is the code to do it. It uses the edgelist instead of the igraph, but it is a cooler looking graph.

    library(qgraph)
    qgraph(mydata,edge.labels=T)

Check out this post for a more detail

Draw Network in R (control edge thickness plus non-overlapping edges)

And this help page for using qgraph: http://rgm3.lab.nig.ac.jp/RGM/R_rdfile?f=qgraph/man/qgraph.Rd&d=R_CC



来源:https://stackoverflow.com/questions/20033565/igraph-package-in-r-edge-labels-are-overlapping

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!