首页 > R-studio出现Error in plot.new() : figure margins too large

R-studio出现Error in plot.new() : figure margins too large

''' r
set.seed(20)
x<- rnorm(100)
e<- rnorm(100,0,2)
y<- 0.5 + 2*x + e
summary(y)
plot(x,y)
'''

如上代码,window系统R-studio(Version 0.98.507)出现
Error in plot.new() : figure margins too large的错误提示。如图:

但是,在R程序上运行这段代码时,能够正常绘图:


很简单,

把散点图显示窗口拉大就好


问题在于画图时的边界空白行数(或列数)较大,因此报错。
可以用par("mar")查看默认的边界设置:

> par("mar")
 [1] 5.1 4.1 4.1 2.1

然后在画图时,对“mar”参数进行用户自定义就可以了。

opar <- par(no.readonly = TRUE)
par(mar = rep(2, 4))    # to be simple
# Plot Code
par(opar)

有时候编译器会出问题,重启试试,我这里是完全可以显示的。。。

【热门文章】
【热门文章】