【问题标题】:Why are my plots not written to disk?为什么我的绘图没有写入磁盘?
【发布时间】:2016-01-19 12:56:29
【问题描述】:

我的绘图没有写入磁盘有什么原因吗?我正在根据this description 保存我的地块,但它不起作用。每个情节只是一个白色图像。为什么会这样?

这是我正在使用的完整脚本;

library(rAltmetric)
library(aRxiv)

print('Load DOIs ..')

doi_list <- list()

categ <- c(AP = 'cat:stat.AP',
           CO = "cat:stat.CO", # I'm naming these elements so
           ME = "cat:stat.ME", # that the corresponding elements
           TH = "cat:stat.TH", # in the list are named as well.
           ML = "cat:stat.ML") # Could also just set 'names(doi_list)' to 'categ'.

doi_list <- 
  lapply(categ, function(ctg)
    (doi <- arxiv_search(ctg)$doi)[nchar(doi) > 0])

print('Showing altmetrics ..')

num = 0

for(category in doi_list) {

  for(mydoi in category) {
    print(paste('Searching DOI:', mydoi))

    #acuna <- altmetrics(doi=mydoi)
    acuna <- altmetrics(doi="10.1038/489201a")

    if(is.null(acuna)) {
      next
    }

    print(acuna)

    acuna_data <- altmetric_data(acuna)
    jpeg(filename=paste(num, ".jpg", sep=""))
    plot(acuna, main=paste(num, ".jpg", sep=""))
    dev.off()
    num <- num + 1
  }
}

print('All done.')

【问题讨论】:

标签: r


【解决方案1】:

我很确定这是R FAQ 7.22

7.22 为什么格子/格子图形不起作用?

最可能的原因是您忘记告诉 R 显示图表。 xyplot() 等格函数创建图形对象,但不显示它(ggplot2 图形和 S-PLUS 中的格状图形也是如此)。图形对象的print() 方法产生实际显示。当您在命令行交互地使用这些函数时,结果会自动打印出来,但是在source() 或您自己的函数中,您将需要一个显式的print() 语句。

使用

print(plot(acuna, main=paste(num, ".jpg", sep="")))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-16
    • 2010-09-28
    • 2016-01-12
    • 1970-01-01
    • 2017-10-26
    • 2013-06-21
    • 2012-01-31
    • 1970-01-01
    相关资源
    最近更新 更多