Why the graph is not proper in R?

强颜欢笑 提交于 2019-12-13 03:39:35

问题


I wanted to plot the graph from the adjacency matrix. As a first step, I have tried the following code.

   set.seed(1)
   library('igraph');
   adjm1<-matrix(sample(0:1,100,replace=TRUE,prob=c(0.9,01)),nc=10); 
   g1<-graph.adjacency(adjm1); 
   plot(g1)

But it gave me, the following graph.

What is the mistake here?

PS: I am using

Rstudio Version 1.1.442 
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows >= 8 x64 (build 9200)

回答1:


It seems for whatever reason the default arrow size on your system is too large. One can specify the arrow size in the plot statement. Example: edge.arrow.size = 0.5

set.seed(1)
library('igraph');

adjm1<-matrix(sample(0:1,100,replace=TRUE,prob=c(0.9,01)),nc=10); 
g1<-graph.adjacency(adjm1); 

plot(g, edge.arrow.size = 0.1)

From similar question: igraph - plotting directed network creates triangular edges



来源:https://stackoverflow.com/questions/50685421/why-the-graph-is-not-proper-in-r

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