r中的igraph包:边缘标签重叠

时间:2013-11-17 17:05:51

标签: r plot igraph

我正在使用R中的igraph包来可视化网络流。

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)

如您所见,我的边缘标签(箭头标签)重叠。怎么解决这个?

提前致谢!

1 个答案:

答案 0 :(得分:1)

这是执行此操作的代码。它使用edgelist而不是igraph,但它看起来更酷。

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

查看此帖子了解更多详情

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

这个使用qgraph的帮助页面: http://rgm3.lab.nig.ac.jp/RGM/R_rdfile?f=qgraph/man/qgraph.Rd&d=R_CC