Save all plots already present in the panel of Rstudio

后端 未结 5 1370
一生所求
一生所求 2021-02-02 12:10

I\'ve made different plots (more than a hundred) for a project and I haven\'t capture them on the way (yes it\'s bad , i know). Now, I need to save them all at once but without

5条回答
  •  感情败类
    2021-02-02 12:47

    If your plots are 3d, you can take a snapshot of all your plots and save them as a .png file format.

    snapshot3d(filename = '../Plots/SnapshotPlots.png', fmt = 'png')
    

    Or else, the best way is to create a multi-paneled plotting window using the par(mfrow) function. Try the following

    plotsPath = "../Plots/allPlots.pdf"
    pdf(file=plotsPath)  
    
        for (x in seq(1,100))   
        {   
          par(mfrow = c(2,1))
          p1=rnorm(x)  
          p2=rnorm(x)  
          plot(p1,p2)   
        } 
        dev.off() 
    

    You can also use png, bmp, tiff, and jpeg functions instead of pdf. You can read their advantages and disadvantages and choose the one you think is good for your needs.

提交回复
热议问题