Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.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
Graphics 如何更改当前打印窗口大小(以R为单位)_Graphics_R_Window_Plot_Base - Fatal编程技术网

Graphics 如何更改当前打印窗口大小(以R为单位)

Graphics 如何更改当前打印窗口大小(以R为单位),graphics,r,window,plot,base,Graphics,R,Window,Plot,Base,比如说。假设我: dev.new(width=5, height=4) plot(1:20) 现在我想做什么 plot(1:40) 但是我想要一个更大的窗户 我猜这样做的方法是(假设我不想打开一个新窗口)去做 这当然行不通 我看到的唯一解决办法是关掉窗户,重新开一扇。(这将结束我的绘图历史) 有更好的办法吗 谢谢。以下是我的解决方案: resize.win <- function(Width=6, Height=6) { # works for windows

比如说。假设我:

dev.new(width=5, height=4)
plot(1:20)
现在我想做什么

plot(1:40)
但是我想要一个更大的窗户

我猜这样做的方法是(假设我不想打开一个新窗口)去做

这当然行不通

我看到的唯一解决办法是关掉窗户,重新开一扇。(这将结束我的绘图历史)

有更好的办法吗


谢谢。

以下是我的解决方案:

resize.win <- function(Width=6, Height=6)
{
        # works for windows
    dev.off(); # dev.new(width=6, height=6)
    windows(record=TRUE, width=Width, height=Height)
}
resize.win(5,5)
plot(rnorm(100))
resize.win(10,10)
plot(rnorm(100))

resize.win一些解决方法可能是,而不是使用dev.new()R函数使用此函数,该函数应跨平台工作:

 dev.new <- function(width = 7, height = 7) 
 { platform <- sessionInfo()$platform if (grepl("linux",platform)) 
 { x11(width=width, height=height) } 
 else if (grepl("pc",platform)) 
 { windows(width=width, height=height) } 
 else if (grepl("apple", platform)) 
 { quartz(width=width, height=height) } }

dev.new Tal从您的示例(宽度增加2倍)来看,您似乎希望能够大幅增加绘图区域。如果打印区域的增加较小,则可以将四个边距向后移动,例如,par(mar=c(3.0,3.0,1.5,1.5))。要调整当前窗口的大小?一旦打开窗口,它“属于”窗口管理器。我不知道任何电话,允许您调整大小和已经打开的窗口。你可以在代码中作弊和模拟“鼠标激活窗口并放大”,但我觉得它的成本效益比很低。你好,道格,谢恩和菲克-谢谢你的回答。我的情况是,我要做一个关于R的演讲,在这个演讲中,我打算在par(mfrow=c(1,1))和par(mfrow=c(1,2))之间来回移动。这将破坏图像比例,并将迫使我调整窗口大小。我在代码中找到的唯一解决方法是关闭并打开一个新窗口,但这会使我无法存储绘图的历史记录。我希望我的问题现在更清楚了。最好是“仅适用于Windows”的帮助(dev.new)和帮助(dev.set)。Brian Ripley试图向您解释,没有其他系统具有windows的功能。
。但我想这也是一件事。。。最好的,Tal
sessionInfo()$platform
在我的系统上返回
“x86_64-w64-mingw32/x64(64位)”
 dev.new <- function(width = 7, height = 7) 
 { platform <- sessionInfo()$platform if (grepl("linux",platform)) 
 { x11(width=width, height=height) } 
 else if (grepl("pc",platform)) 
 { windows(width=width, height=height) } 
 else if (grepl("apple", platform)) 
 { quartz(width=width, height=height) } }