I'm trying to plot a graph with layout_on_grid and receiving the message
Warning message: In if (axes) { : the condition has length > 1 and only the first element will be used
It not only gives the warning, but don't apply the expected layout.
It does not seem to be an issue from the graph itself
library(igraph)
rG <- erdos.renyi.game(25,0.2)
plot(rG)
but with the layout, the warning.
plot(rG, layout_on_grid(rG, dim=2))
I have tested with directed and undirected edges and with edges with null or positive weights.
and the layout works here
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))
Any ideas I could be doing wrong here?
The 2nd argument of plot.igraph
is axes
. You were effectively giving it a matrix, where it wants a logical TRUE/FALSE value. So it used the first value of the matrix, coerced it to a boolean value and threw out a warning.
After adding the layout
argument it will work as expected:
plot(rG, layout=layout_on_grid(rG, dim=2))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.