以下代码创建并绘制了包含4个节点和标准法线边缘的图形:
library(igraph)
set.seed(1)
adjmat <- matrix(rnorm(16), 4, 4); adjmat <- 1/2 * (adjmat + t(adjmat)); diag(adjmat) <- 0
ig <- graph_from_adjacency_matrix(adjmat, "undirected",
weighted = TRUE, diag = FALSE)
edge_col <- function(x, alpha)
ifelse(x > 0, rgb(0,0,1,alpha = alpha), rgb(1,0,0,alpha = alpha))
# this works fine
plot(ig, edge.color = edge_col(E(ig)$weight, alpha = 1))
# no edges show up in plot
plot(ig, edge.color = edge_col(E(ig)$weight, alpha = 0.9))
使用alpha
中的不透明度参数rgb
设置颜色透明度。为什么alpha < 1
时没有边缘显示?
感谢。