Reputation: 1360
I try to plot multiple igraph
graphs in one figure using the gridExtra
package
require(igraph)
require(gridExtra)
er_graph <- erdos.renyi.game(100, 5/100)
coords<-layout.fruchterman.reingold(er_graph)
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))
plot(er_graph,layout=coords, vertex.label=NA, vertex.color='red',main='red graph')
plot(er_graph,layout=coords, vertex.label=NA, vertex.color='blue',main='blue graph')
but the result was two separate graphs instead of grid of two graphs.
Any idea how to plot multiple igraph
graphs on the same figure?
Upvotes: 2
Views: 2496
Reputation: 786
Try,
par(mfrow=c(2,1))
plot(er_graph,layout=coords, vertex.label=NA, vertex.color='red',main='red graph')
plot(er_graph,layout=coords, vertex.label=NA, vertex.color='blue',main='blue graph')
You'll have to mess with the margins (par(mar=)) a bit so that the graphs takes up the whole space.
Upvotes: 3