我需要将绘图对象存储在变量中。我知道我能做到:
plot(rnorm(10))
obj = recordPlot()
replayPlot(obj)
但我不想显示图形窗口。所以我正在尝试这样做,但到目前为止还没有成功。
win.metafile()
plot(rnorm(10))
obj = recordPlot()
dev.off()
replayPlot(obj) # it shows a null plot
嗯,可能是因为当我执行 obj = recordPlot()
时,绘图尚未准备好。
最佳答案
来自?recordPlot
:
The displaylist can be turned on and off using dev.control.
Initially recording is on for screen devices, and off for print devices.
因此,如果您想记录写入文件的绘图,则需要打开显示列表:
win.metafile()
dev.control('enable') # enable display list
plot(rnorm(10))
obj = recordPlot()
dev.off()
replayPlot(obj)
关于R 绘图不显示图形窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23767645/