layout_on_grid 的 Igraph 包 R 问题
Igraph package R issue with layout_on_grid
我正在尝试用 layout_on_grid 绘制图表并收到消息
Warning message: In if (axes) { : the condition has length > 1 and
only the first element will be used
它不仅给出了警告,而且没有应用预期的布局。
从图表本身来看这似乎不是问题
library(igraph)
rG <- erdos.renyi.game(25,0.2)
plot(rG)
如我们所见
但随着布局,警告。
plot(rG, layout_on_grid(rG, dim=2))
我已经测试了有向和无向边以及具有空权重或正权重的边。
这里的布局有效
el <- matrix(nc=3, byrow=TRUE,
c(1,2,0, 1,3,2, 1,4,1, 2,3,0, 2,5,5, 2,6,2, 5,2,1, 3,4,1,
3,7,1, 4,3,0, 4,7,2, 5,6,2, 5,8,8, 6,3,2, 6,7,1, 6,9,1,
6,4,3, 8,6,1, 8,9,1, 7,10,4) )
g <- add_edges(make_empty_graph(10), t(el[,1:2]), weight=el[,3])
plot(g)
plot(g, layout=layout_on_grid(g, width = 4))
有什么我可能做错的想法吗?
plot.igraph
的第二个参数是 axes
。您实际上是在给它一个矩阵,它需要一个逻辑 TRUE/FALSE 值。所以它使用矩阵的第一个值,将其强制转换为布尔值并发出警告。
添加 layout
参数后,它将按预期工作:
plot(rG, layout=layout_on_grid(rG, dim=2))
我正在尝试用 layout_on_grid 绘制图表并收到消息
Warning message: In if (axes) { : the condition has length > 1 and only the first element will be used
它不仅给出了警告,而且没有应用预期的布局。
从图表本身来看这似乎不是问题
library(igraph)
rG <- erdos.renyi.game(25,0.2)
plot(rG)
如我们所见
但随着布局,警告。
plot(rG, layout_on_grid(rG, dim=2))
我已经测试了有向和无向边以及具有空权重或正权重的边。
这里的布局有效
el <- matrix(nc=3, byrow=TRUE,
c(1,2,0, 1,3,2, 1,4,1, 2,3,0, 2,5,5, 2,6,2, 5,2,1, 3,4,1,
3,7,1, 4,3,0, 4,7,2, 5,6,2, 5,8,8, 6,3,2, 6,7,1, 6,9,1,
6,4,3, 8,6,1, 8,9,1, 7,10,4) )
g <- add_edges(make_empty_graph(10), t(el[,1:2]), weight=el[,3])
plot(g)
plot(g, layout=layout_on_grid(g, width = 4))
有什么我可能做错的想法吗?
plot.igraph
的第二个参数是 axes
。您实际上是在给它一个矩阵,它需要一个逻辑 TRUE/FALSE 值。所以它使用矩阵的第一个值,将其强制转换为布尔值并发出警告。
添加 layout
参数后,它将按预期工作:
plot(rG, layout=layout_on_grid(rG, dim=2))