How to save a plot as image on the disk?

后端 未结 11 1222
失恋的感觉
失恋的感觉 2020-11-22 10:38

I plot a simple linear regression using R. I would like to save that image as PNG or JPEG, is it possible to do it automatically? (via code)

There are two different

11条回答
  •  独厮守ぢ
    2020-11-22 10:54

    If you open a device using png(), bmp(), pdf() etc. as suggested by Andrie (the best answer), the windows with plots will not pop up open, just *.png, *bmp or *.pdf files will be created. This is convenient in massive calculations, since R can handle only limited number of graphic windows.

    However, if you want to see the plots and also have them saved, call savePlot(filename, type) after the plots are drawn and the window containing them is active.

提交回复
热议问题