【4.1】plot new() figure margins too large

案例:

> def.par <- par(no.readonly = TRUE)
> nf <- layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE)
> layout.show(nf)
> plot(x=ds$gc,y=ds$coverage)
> plot(x=ds$gc,y=ds$coverage)
> plot(x=ds$gc,y=ds$coverage)

错误于plot.new() : figure margins too large

**       

这个错误本质上来讲就是画的图在画布上展不开**。有两个原因:

  1. 画布大小过小
  2. 当前画布的上下左右距离过大

解决第一个问题的方法:

就是拖动Rstudio的画布,让画布的区域大一点。

解决第二个问题的方法:

绘图边距太大了,所以我们需要设置绘图边距,但是在设置的时候也需要考虑不同的区域绘图边距大小需要合适。 默认的画布上边款的距离为:

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. The default is c(5, 4, 4, 2) + 0.1.

我们可以讲其设置为0. 对于一个空白的界面来说,你组好完全关掉绘图边距

op <- par(mar = rep(0, 4))
plot.new()
par(op)

#rep就是复制数据,replication 。rep(x,times),x为要复制的数据 times是要重复的次数。

#绘图边距可以使用par()函数中mar来设置比如mar=c(4,3,2,1),与外围边距的设置类似,是指绘图边距分别为下边距:4行,左边距3行,上边距2行,右边距1行

参考资料:

炼数成金 http://f.dataguru.cn/thread-11599-1-1.html

同时感谢QQ好友Ophelin

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn