R 绘图不显示图形窗口

标签 r plot

我需要将绘图对象存储在变量中。我知道我能做到:

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/

相关文章:

r - 根据 R 中的多列条件查找百分比

python - panda 根据某一​​列绘制多条线

r - 绘图轴标题上的特殊字符和上标

r - 如何在 GGally 中使用您自己的密度函数创建较低密度图

r - 在 R 中搜索多个术语

r - 将残差绑定(bind)到具有缺失值的输入数据集

r - 突出显示 ggplot2 stat_qq 输出中的点

r - 每个框中带有标签的马赛克图,显示所有观察值的名称和百分比

python 和 Basemap 并从 View 中删除墨西哥/加拿大

python - 分层树的视觉替代方案 : (((A, B),(C,D)),E)?