我该如何在同一时间绘制多个设备? [英] How can I plot to multiple devices at the same time?
本文介绍了我该如何在同一时间绘制多个设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我绘图时,我经常将一个 eps
文件和一个 png
文件打成这样:
When I am plotting, I often plot to an eps
file and a png
file like this:
postscript(file=paste(dir, output, "_ggplot.eps", sep=""), onefile=FALSE, horizontal=FALSE, width=4.8, height=4.0)
# Plotting code
dev.off()
png(paste(dir, output, "_ggplot.png", sep=""), width=450, height=300)
# Plotting code
dev.off()
问题在于绘图代码重复两次。是否可以指定多个设备进行绘图?
The problem is that the plotting code is repeated twice. Is it possible to specify multiple devices for plotting?
推荐答案
您可以使用 dev.copy )
。例如,
You can combine them using dev.copy()
. For example,
X11 ()
plot (x,y)
dev.copy (jpeg,filename="test.jpg");
dev.off ();
查找 help(dev.copy)
for更多细节。
Lookup help(dev.copy)
for more details.
Usage:
dev.copy(device, ..., which = dev.next())
dev.print(device = postscript, ...)
dev.copy2eps(...)
dev.copy2pdf(..., out.type = "pdf")
dev.control(displaylist = c("inhibit", "enable"))
这篇关于我该如何在同一时间绘制多个设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文