如何改变R中igraph中边缘的强度和对称性?

问题描述

我希望制作一个类似于此的图表:

enter image description here

其中不仅顶点根据其值具有不同的大小,而且边缘根据值/力具有不同的宽度。

我在这里有这个数据集:

    data = structure(c(NA,0.003122927,0.00999241,0.008685473,0.007730365,0.003573423,NA,0.18893711,0.183237263,0.139293056,0.120902907,0.132071652,0.457142857,0.114500717,0.322255215,0.097676062,0.261095249,0.131416203,0.146191646,0.086854728,0.023023646,0.080959767,0.034786642,0.09469697,0.024480341,0.049917782,0.042613636,0.255554962,0.765625,0.040201005,0.041930937,0.192970073,0.030562035,0.151121606,0.039751553,0.026693325,0.011428571,NA),.Dim = c(23L,23L),.Dimnames = list(c("sp1","sp2","sp3","sp4","sp5","sp6","sp7","sp8","sp9","sp10","sp11","sp12","sp13","sp14","sp15","sp16","sp17","sp18","sp19","sp20","sp21","sp22","sp23"),c("sp1","sp23")))

这是我的脚本:

library (igraph)
    
View (data)

class (data)

data= data.matrix(data,rownames.force = NA)

class (data)

graph <- graph_from_adjacency_matrix(data,mode = "directed",weighted = TRUE)

as_edgelist(graph,names=F)

as_adjacency_matrix(graph,attr="weight")

as_data_frame(graph,what="edges")

as_data_frame(graph,what="vertices")

graph = simplify(graph,edge.attr.comb=list(weight="sum","ignore"))


deg <- degree(graph,mode="all")

L <- layout_in_circle(graph)


plot(graph,edge.arrow.size=.1,vertex.color="black",vertex.size=deg*1.5,vertex.frame.color="black",vertex.label.color="grey10",vertex.label.degree=-pi/6,vertex.shape="circle",vertex.label.cex=1,vertex.label.dist=2,vertex.label.font=1,edge.arrow.size=8,edge.width=0,edge.curved=0,edge.color="black",edge.lty=1,layout=L)

上面的这段代码为我生成了这张图:

enter image description here

有人可以帮我吗?我真的很困惑。我对图表没有太多经验。谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...