如何使用图表来源的数据名称来标题图?

时间:2016-10-13 14:16:39

标签: r for-loop plot title igraph

我有一个igraph对象的列表,我正在从(使用forloop)生成图表,我想给每个图形一个从它来自的对象派生的标题。有谁知道我怎么做到这一点?

这是我目前的代码:

for (i in glst){
 i=delete.vertices(i,which(degree(i)<1))
 plot(i)
 legend(x=-2, y=-0.3, c('nest', 'tree'), pch=21,
     col="#777777", pt.bg= c('orangered3','forestgreen'), pt.cex=2, 
     cex=1, bty="n", ncol=1)
}

其中glst是igraph对象列表(称为colony12012,colony12013a .....等)

1 个答案:

答案 0 :(得分:0)

您可以尝试循环names(glst),因此for (i in glst)变为for (name in names(glst))

然后i=delete.vertices(i,which(degree(i)<1))变为i = delete.vertices(glst[[name]], which(degree(glst[[name]]) < 1)),因此您可以添加title(main = name)