I have about two dozen networks that I want to plot using the same layout (they all share the same vertices). I'm new to R and igraph, so I have come up with this solution, which probably isn't very elegant. Now I'm stuck though. I'd like to know how I can get object names (in this case: V_turn1 etc.) into my plot titles and, if possible, into the file names.
I have added some random networks to make it easier to make it reproducible. It goes a little something like this:
print("begin")
library("igraph")
V_turn1 <- erdos.renyi.game(n=10,p.or.m=.2,type="gnp",directed=T)
V_turn2 <- erdos.renyi.game(n=10,p.or.m=.1,type="gnp",directed=T)
V_turn3 <- erdos.renyi.game(n=10,p.or.m=.3,type="gnp",directed=T)
V_turn4 <- erdos.renyi.game(n=10,p.or.m=.3,type="gnp",directed=T)
layout.old <- layout.random(V_turn1)
# I need the same layout for all renderings, because the nodes are all the same across my network data
list_of_graphs <- c("V_turn1", "V_turn2", "V_turn3", "V_turn4")
png(file="Networks_V3_%03d.png", width=1000,height=1000)
for(i in list_of_graphs){
plot(get(i), layout=layout.old)
title(deparse(list_of_graphs))
}
dev.off()
"deparse(list_of_graphs)" obviously doesn't work...
Actually, I'd be even happier if I could specify real titles for each iteration of the loop, i.e. in a new character vector or something (like "This is Turn 1" for V_turn1). I feel like there must be an obvious solution, but I so far nothing I've tried worked. Thank you for reading.