【问题标题】:turn off the saveGIF display RStudio关闭 saveGIF 显示 RStudio
【发布时间】:2020-02-22 23:29:30
【问题描述】:

我想知道,如何关闭我制作的 .GIF 的弹出窗口?我已经创建并使用了这段代码:

reswd <- "c:/Data/GIF/"

if(!file.exists(paste0(reswd,"Seasonal.gif"))) { # Check if the file exists

  suppressMessages(saveGIF({

    for (i in 1:dim(tmp_Stack1)[3]) plot(tmp_Stack1[[i]],
                                         main=names(tmp_Stack1)[i],
                                         legend=FALSE,
                                         col = c("green", "blue"),
                                         breaks=c(0,.000000000000000000001,1)
)
     },
    movie.name = paste0(reswd,"Seasonal.gif"), 
    ani.width = 480, ani.height = 400, 
    interval=.5))
  }

我已尝试使用“suppressMessages”但不起作用。 但是在最后保存文件时会显示。感谢所有未来的答案!

【问题讨论】:

    标签: r rstudio


    【解决方案1】:

    我已经像这样解决了我的问题。也许有点混乱,但我会尝试整理更多我结合 XD 的新代码。我希望有人也有新的方法来做到这一点。

    setwd("c:/Data/Total_Water_Color/")
    for (i in 1:dim(tmp_Stack3)[3]){
      png(filename=paste0(names(tmp_Stack3)[i],".png"), width = 480, height = 400)
    
    
      plot(tmp_Stack3[[i]],
           main=names(tmp_Stack3)[i],
           legend=FALSE,
           col = c("green", "blue"),
           breaks=c(0,.000000000000000000001,1))
    
      dev.off()
    }
    

    接下来的代码是创建GIF,完成后不弹出。

    setwd("c:/Data/GIF/")
    list.files(path="c:/Data/Total_Water_Color/", pattern = '*.png', full.names = TRUE) %>% 
      image_read() %>% # reads each path file
      image_join() %>% # joins image
      image_animate(fps=1) %>% # animates, can opt for number of loops
      image_write("Total.gif") # write to current dir
    

    如果有人有更好的答案,我愿意听到任何其他更好,也许更短的一个选项。

    【讨论】:

      猜你喜欢
      • 2023-02-21
      • 2021-12-19
      • 2022-01-18
      • 1970-01-01
      • 2016-10-22
      • 2019-10-13
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      相关资源
      最近更新 更多