igraph保存绘图不使用输出文件名作为对象

时间:2017-03-15 12:42:47

标签: r plot igraph

我遵循了igraph的saving plot文档,但我需要遍历一个图表列表并且它不起作用:

for (f in flist) {
    df <- read.table(f, header=TRUE, sep='\t', quote='', comment.char='')
    png <- paste0(f, '.png')
    g <- graph_from_data_frame(df, directed = FALSE)
    plot(g, png)
}

我尝试了plot(g, png)plot(g, file=png)plot(g, save=png)plot.igraph(g, png)plot.igraph(g, file=png)plot.igraph(g, save=png)。它们都不起作用。

Error in if (axes) { : argument is not interpretable as logical

或者

Error in i.parse.plot.params(graph, list(...)) : 
Unknown plot parameters: save

1 个答案:

答案 0 :(得分:0)

for (f in flist) {
    df <- read.table(f, header=TRUE, sep='\t', quote='', comment.char='')
    png <- paste0(f, '.png')
    g <- graph_from_data_frame(df, directed = FALSE)
    plot(g, png)
    png("/YOUR PATH/XXX.png")
    plot(g)
    dev.off()
}