Graph R的图中的比例链接或节点大小?

Graph R的图中的比例链接或节点大小?,graph,igraph,bipartite,sna,Graph,Igraph,Bipartite,Sna,有没有办法在igraph中为R绘制与最小值和最大值成比例的网络链路或节点 在igraph中,使用链接和节点属性进行绘制非常方便,但在某些网络中,网络中的最小值和最大值之间的差异会导致绘制非常难看的图形。例如,请参见以下代码: #Transforming a sample network (Safariland) from the package bipartite into an igraph object mat = Safariland mat2 = cbind.data.frame(ref

有没有办法在igraph中为R绘制与最小值和最大值成比例的网络链路或节点

在igraph中,使用链接和节点属性进行绘制非常方便,但在某些网络中,网络中的最小值和最大值之间的差异会导致绘制非常难看的图形。例如,请参见以下代码:

#Transforming a sample network (Safariland) from the package bipartite into an igraph object
mat = Safariland
mat2 = cbind.data.frame(reference=row.names(mat),mat)
list = melt(mat2, na.rm = T)
colnames(list) = c("plant","animal","weight")
list[,1] = as.character(paste(list[,1]))
list[,2] = as.character(paste(list[,2]))
list2 = subset(list, weight > 0)
g = graph.data.frame(list2)
g2 = as.undirected(g)

#Plotting the igraph object with edge widths proportional to link weights
plot(g2,
 edge.width = E(g2)$weight)
结果是一个看起来很奇怪的网络,因为链接权重之间的差异太大了。如何在最小-最大范围内绘制这些边,使网络看起来更好


非常感谢。

在将值传递给绘图函数之前,您可以对值应用任何数学或函数。 例如,您需要的是:

更好的打印,首先使用上述功能将边权重重新缩放为1到10之间的值:

weightsRescaled<-mapToRange(E(g)$weight,1,10)
plot(g, edge.width = weightsRescaled)
library(igraph)
g<-erdos.renyi.game(20,0.5)
E(g)$weight<-runif(length(E(g)))^3 *100
plot(g, edge.width = E(g)$weight)
weightsRescaled<-mapToRange(E(g)$weight,1,10)
plot(g, edge.width = weightsRescaled)
plot(g, edge.width = mapToRange(E(g)$weight,1,10))