使用 igraph 绘制网络时出现巨大的箭头

Jus*_*yna 5 plot social-networking igraph

编辑 我试图找出我的代码有什么问题,我开始绘制简单的图形以查看箭头在较小图形上的外观。我厌倦了以下命令:

 g2 <- graph( edges=c(1,2, 2,3, 3, 1), n=10 ) 
 plot(g2)   
Run Code Online (Sandbox Code Playgroud)

这是我的图表: . 因此,我认为问题不在于我的代码,而在于 igraph 或 R。我重新安装了 igraph 和 R,但没有解决问题。是否可能存在导致此问题的软件包冲突?这是我安装的一些软件包:

 [1] "base"         "boot"         "class"        "cluster"     
 [5] "codetools"    "colorspace"   "compiler"     "datasets"    
 [9] "dichromat"    "digest"       "doParallel"   "foreach"     
[13] "foreign"      "graphics"     "grDevices"    "grid"        
[17] "gridBase"     "gtable"       "igraph"       "irlba"       
[21] "iterators"    "KernSmooth"   "labeling"     "lattice"     
[25] "lazyeval"     "magrittr"     "MASS"         "Matrix"      
[29] "methods"      "mgcv"         "munsell"      "nlme"        
[33] "NMF"          "nnet"         "parallel"     "pkgmaker"    
[37] "plyr"         "RColorBrewer" "Rcpp"         "registry"    
[41] "reshape2"     "rngtools"     "rpart"        "scales"      
[45] "spatial"      "splines"      "stats"        "stats4"      
[49] "stringi"      "stringr"      "survival"     "tcltk"       
[53] "tibble"       "tools"        "utils"        "xtable"    
Run Code Online (Sandbox Code Playgroud)

我正在尝试生成网络图,出于某种原因,我的箭头看起来像小矩形,而不是通常的三角形箭头。

这是我用于绘图的代码:

toy.edges <- na.omit(read.csv("Data/Edge_list-toy.csv", header = TRUE, colClasses = "numeric", na.strings = c("NA", "", "#N/A")))
toy.nodes <- na.omit(read.csv("Data/NodesDataF-toy.csv", header = TRUE, na.strings = c("NA", "", "#N/A")))
toy.graph <- graph_from_data_frame(toy.edges, directed = TRUE, vertices = toy.nodes)

V(toy.graph)$color <- "magenta" 
V(toy.graph)$shape <- "sphere"
V(toy.graph)$size <- 3*15^(ifelse(is.na(V(toy.graph)$node.size), 0.001, 
V(toy.graph)$node.size))
plot(toy.graph, layout = layout.fruchterman.reingold(toy.graph),
     vertex.label=NA, edge.width=E(toy.graph)$weight, 
     edge.arrow.size=0.005, edge.arrow.width=0.0000001)
Run Code Online (Sandbox Code Playgroud)

这是一个示例图:

[1]:https://i.stack.imgur.com/iCx

当我为edge.arrow.size and取稍大的值时,它看起来更糟edge.arrow.width

我的代码有什么问题?和R的版本有关系吗?我以前使用非常相似的命令制作了大量图,但从未遇到过问题。

这是包含节点信息边列表的文件

Jus*_*yna 2

所以问题似乎出在 R 如何在我的计算机上显示图形。当我不是直接在控制台中绘制图形,而是将其保存到文件中时,一切看起来都很好。这是我正在使用的代码,以防其他人遇到类似的问题:

png("my-plot.png", width=1200, height=1200)
par(mar=c(0,0,0,0))
plot(mat_gr, layout = layout.auto(mat_gr), vertex.label=NA,   
     edge.width=E(mat_gr)$weight)
dev.off()
Run Code Online (Sandbox Code Playgroud)

我意识到它不能解决显示巨大箭头的问题,但至少它允许生成保存可用的绘图。