Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在多打印窗口中打印到特定打印?_R_Plot - Fatal编程技术网

R 在多打印窗口中打印到特定打印?

R 在多打印窗口中打印到特定打印?,r,plot,R,Plot,如果我使用par(mfrow=…)创建了一个多打印窗口,是否可以将数据发送到特定的打印(即“左下角的打印”),或者打印总是必须按顺序进行?有没有一个R包可以做这样的事情 对于那些感兴趣的人来说,这个问题是因为R是一个单线程应用程序,不适合实时可视化。我有多个实时数据流从异步生成数据的外部源进入R(因此数据流的顺序并不总是相同)。这导致R在每次更新时都会围绕数据可视化绘图的顺序翻转。请查看帮助(布局)。这允许您指定什么、在哪里以及在什么大小 一旦绘制,我不认为你只是部分地绘制。但您可以使用dev.

如果我使用
par(mfrow=…)
创建了一个多打印窗口,是否可以将数据发送到特定的打印(即“左下角的打印”),或者打印总是必须按顺序进行?有没有一个R包可以做这样的事情

对于那些感兴趣的人来说,这个问题是因为R是一个单线程应用程序,不适合实时可视化。我有多个实时数据流从异步生成数据的外部源进入R(因此数据流的顺序并不总是相同)。这导致R在每次更新时都会围绕数据可视化绘图的顺序翻转。

请查看
帮助(布局)
。这允许您指定什么、在哪里以及在什么大小


一旦绘制,我不认为你只是部分地绘制。但您可以使用
dev.set()
等在不同的“绘图设备”(即windows)之间切换;请参阅
帮助(dev.list)

您可以使用
split.screen()


另一个选项是实现一个小型GUI,例如使用
RGtk2
RTclTk

我通常这样做的图形,我想改变在实时和它的伟大作品

例如,使用
RGtk2
cairoDevice
您可以执行以下操作(我假设您有一个Glade接口)

#从Glade界面获取小部件的助手函数

getWidget注意,这里建议的答案是使用split.screen()。它可能会工作,但根据split.screen帮助文件:“使用这些功能的建议方法是完全绘制绘图和所有添加(即点和线)在选择并在另一个屏幕上打印之前,返回到基本绘图。返回屏幕以添加到现有绘图的行为不可预测,可能会导致不易看到的问题。”

在回答我的问题时,有一个更有用的解决方案,使用par(制造商)选项:


注意使用:par(bg=“white”)的重要性
par(bg = "white") # erase.screen() will appear not to work
                  # if the background color is transparent 
                  # (as it is by default on most devices).
split.screen(c(2,1)) # split display into two screens
split.screen(c(1,3), screen = 2) # now split the bottom half into 3
screen(1) # prepare screen 1 for output
plot(10:1)
screen(4) # prepare screen 4 for output
plot(10:1)
# Helper function to get a widget from the Glade interface
getWidget <- function(name)
 {
 return (interface$getWidget(name))
 }

interface <- gladeXMLNew("interface.glade", root="mainWindow")
# Our cairo devices (to draw graphics).
# plot1, plot2, and plot3 are GtkDrawingArea widgets 
asCairoDevice(getWidget("plot1"))
# dev.cur() will give the device number of the last device we created
# You'll use this to switch device when you draw in different plots
# Storing the device number is important because you may have other
# devices open from other unrelated plots 
# (so never assume they'll just start from 1 and be sequential!!!)
plot1.dev <- as.integer(dev.cur())
asCairoDevice(getWidget("plot2"))
plot2.dev <- as.integer(dev.cur())
asCairoDevice(getWidget("plot3"))
plot3.dev <- as.integer(dev.cur())

# To draw in a specific plot you just do
dev.set(plot2.dev)
plot(....)