带有非 GUI 设备的 R dev.copy() 用于批处理图形脚本

标签 r graphics plot batch-processing

'dev.copy' 将当前设备的图形内容复制到指定的设备中。如果当前设备是:

windows() # or perhaps X11
plot(1:10)
dev.copy(device=pdf,file='hello.pdf') 
dev.off()
dev.off()

通过这种方法,我们可以将相同的绘图复制到多个设备(格式)。

如果源设备是非 GUI 设备怎么办?我想以批处理模式复制多种格式的绘图,因此_不向用户显示 GUI 窗口。
但是:

png()    # or other non-GUI devs
plot(1:10)
dev.copy(device=pdf,file='hello.pdf') 
dev.off()
dev.off()

没用。事实上,该设备在关闭之前一直是空的,但关闭后,它就不再可用于复制。

有什么想法吗?

最佳答案

您需要调用 dev.control('enable')。来自 ?dev.copy:

dev.copy copies the graphics contents of the current device to the device specified...(If recording is off on the current device, there are no contents to copy: this will result in no plot or an empty plot.) ... The displaylist can be turned on and off using dev.control. Initially recording is on for screen devices, and off for print devices.

关于带有非 GUI 设备的 R dev.copy() 用于批处理图形脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24840979/

相关文章:

python - 如何在甘特图中指示预期日期和实际日期?

c++ - 控制帧速率的常用方法是什么?

java - JApplet setBackground 不工作

javascript - Highcharts - 绘制在 x 轴上曲折的线条时,系列工具提示不起作用

R将corrplot返回为对象

r - 将加权边缘列表转换为 r 中的未加权边缘列表

r - 使用 apply family 函数通过对多个其他列进行操作来创建多个数据框列

r - ggplot2:为每个 x 处的组值总和添加行

java - OpenGL:模型显示不正确。 (需要固定绘制距离吗?)

python - Pandas 散点图 : Indices Out-of-Bounds