如何返回R中的前一帧? [英] How can I return to previous frame in R?

查看:73
本文介绍了如何返回R中的前一帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用简单的布局在R中进行绘图:

 布局(矩阵(c(1,2),1,2)) 

绘制图的两侧后,我需要返回到第一条以绘制另外两条线(跨到另一侧,只有绘制了第二条后,我才知道正确的坐标)./p>

我知道我可以使用frame()在各帧之间移动,但是它只会向前移动,当它返回到开始处时,它将清除整个图形.可以向后移一帧吗?

解决方案

尽管有警告,但在使用布局时,您可以使用 par(mfg = ...)来控制绘图的焦点:

  layout(matrix(1:4,2,2));情节(1:10,1:10);情节(10:1,1:10);par(mfg = c(1,1));背斜(h = 5) 

我不希望dev.set(dev.prev())能够正常工作,因为我认为它们都被写入同一设备.

I'm doing a plot in R using a simple layout:

layout(matrix(c(1,2),1,2))

After I have drawn the two sides of the plot, I need to return to the first to draw two more lines (that span to the other side, and only after drawing the second side I will know the right coordinates).

I know I can use frame() to move between frames, but it only goes forward, and when it returns to the beginning, it clears the whole drawing. Is it possible to move a frame back?

解决方案

Despite the warnings you can use par(mfg=...) to control the focus of plotting when using layout:

layout(matrix(1:4,2,2)); 
plot(1:10, 1:10);
plot(10:1, 1:10);  
par(mfg=c(1,1)); 
abline(h=5)

I would not have expected dev.set(dev.prev()) to work since I think it's all being written to the same device.

这篇关于如何返回R中的前一帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆