虽然手册指出这将是未来的功能:
arrow.size箭头的大小。目前这是一个常数,所以它 每个边缘都是一样的。如果提交了一个向量,那么只有 使用第一个元素,即。如果这是从edge属性获取的 然后只有第一条边的属性用于所有箭头。这个 将来可能会改变。
默认值为1。
我想知道是否存在允许箭头尺寸与边缘宽度相匹配的黑客(每条边都有自己的宽度)。
d <- data.frame(start=c("a","a","b","c"),end=c("b","b","c","b"), size=rnorm(4))
graph <- graph.data.frame(d, directed=T)
plot(graph,
vertex.color="white",
edge.width=E(graph)$size*20,
edge.arrow.size=E(graph)$size)
答案 0 :(得分:10)
嗯,有一个黑客攻击,您需要将图形绘制为不同边缘宽度的数量,并且每次只绘制边缘的给定子集,并使用“右”箭头大小。使用add=TRUE
参数将它们绘制在一起。也许你也想只绘制一次顶点。
顺便说一下。您可以在https://github.com/igraph/igraph/issues
提交功能请求library(igraph)
## (almost) your example data
d <- data.frame(start=c("a","a","b","c"),
end=c("b","b","c","b"),
size=1:4)
graph <- graph.data.frame(d, directed=TRUE)
## The plotting function
eqarrowPlot <- function(graph, layout, edge.lty=rep(1, ecount(graph)),
edge.arrow.size=rep(1, ecount(graph)),
vertex.shape="circle",
edge.curved=autocurve.edges(graph), ...) {
plot(graph, edge.lty=0, edge.arrow.size=0, layout=layout,
vertex.shape="none")
for (e in seq_len(ecount(graph))) {
graph2 <- delete.edges(graph, E(graph)[(1:ecount(graph))[-e]])
plot(graph2, edge.lty=edge.lty[e], edge.arrow.size=edge.arrow.size[e],
edge.curved=edge.curved[e], layout=layout, vertex.shape="none",
vertex.label=NA, add=TRUE, ...)
}
plot(graph, edge.lty=0, edge.arrow.size=0, layout=layout,
vertex.shape=vertex.shape, add=TRUE, ...)
invisible(NULL)
}
## Test
eqarrowPlot(graph, layout.auto(graph), edge.arrow.size=E(graph)$size/3,
edge.width=E(graph)$size)
但很宽的边缘看起来很糟糕。