【发布时间】:2017-10-05 17:44:48
【问题描述】:
编辑 我试图找出我的代码有什么问题,然后我开始绘制简单的图表,以查看箭头在较小的图表上的外观。我厌倦了以下命令:
g2 <- graph( edges=c(1,2, 2,3, 3, 1), n=10 )
plot(g2)
这是我的图表:。因此,我认为问题不在于我的代码,而在于 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"
我正在尝试生成网络图,出于某种原因,我的箭头看起来像小矩形,而不是通常的三角形箭头。
这是我用于绘图的代码:
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)
这是一个示例图:
当我为 edge.arrow.size 取稍大的值时,它看起来更糟
和edge.arrow.width。
我的代码有什么问题?它与R的版本有关吗?我之前用非常相似的命令做了很多图,我从来没有遇到过问题。
这里是带有nodes info 和edge list 的文件。
【问题讨论】:
标签: plot social-networking igraph