这确实是 igraph 中的一个错误,它发生是因为 igraph 为箭头留出了一些空间,即使箭头不存在。我将在下一个 igraph 版本中修复它。
作为一种解决方法,您可以将每条边绘制两次,彼此重叠。为此,您需要使图形定向,然后使用该edge.arrow.mode
选项来避开箭头。这是因为箭头绘图仪只修改了边缘的一端。以这种方式绘制图表有点愚蠢,但我现在找不到更好的解决方法。正如我所说,新版本(0.6.4之后的版本)不会有这个问题。
library(igraph)
# Zoom in on the critical region, although the gap always has the
# same size, unless you make the plotting window bigger
g <- graph(c(1,2), directed=FALSE)
par(mar=c(0,0,0,0))
plot(g, edge.width=2, vertex.size=20, edge.color='black', main='',
rescale=FALSE, xlim=c(0.9,1), ylim=c(0.9,1),
layout=rbind(c(0,0), c(1,1)), vertex.color="#ffffff11")

# This plot should have no gaps
g2 <- as.directed(g, mode="mutual")
par(mar=c(0,0,0,0))
plot(g2, edge.width=2, vertex.size=20, edge.color='black', main='',
rescale=FALSE, xlim=c(0.9,1), ylim=c(0.9,1),
layout=rbind(c(0,0), c(1,1)), vertex.color="#ffffff11",
edge.arrow.mode="-")
