R plot without showing the graphic window

前端 未结 2 1010
鱼传尺愫
鱼传尺愫 2020-12-21 06:03

I need to store a plot object in a variable. I know that I can do:

plot(rnorm(10))
obj = recordPlot()
replayPlot(obj)

But I don\'t want to

2条回答
  •  暖寄归人
    2020-12-21 06:29

    From ?recordPlot:

    The displaylist can be turned on and off using dev.control. 
    Initially recording is on for screen devices, and off for print devices.
    

    So you need to turn on the displaylist if you want to record a plot writing to file:

    win.metafile()
    dev.control('enable') # enable display list
    plot(rnorm(10))
    obj = recordPlot()
    dev.off()
    replayPlot(obj)
    

提交回复
热议问题