r语言 - 修复 RStudio 的默认 par() 设置



启动RStudio(OSX 10.8.4上的v0.97.551)时,运行plot(1:10, 1:10)失败并显示Error in plot.new() : figure margins too large。 这似乎与具有此错误消息的其他 SO 问题无关,因为它只发生在 RStudio 中 - R 的基本 GUI 不受影响。

par()产量:

> par()
$xlog
[1] FALSE
$ylog
[1] FALSE
$adj
[1] 0.5
$ann
[1] TRUE
$ask
[1] FALSE
$bg
[1] "white"
$bty
[1] "o"
$cex
[1] 1
$cex.axis
[1] 1
$cex.lab
[1] 1
$cex.main
[1] 1.2
$cex.sub
[1] 1
$cin
[1] 0.2000000 0.2666667
$col
[1] "black"
$col.axis
[1] "black"
$col.lab
[1] "black"
$col.main
[1] "black"
$col.sub
[1] "black"
$cra
[1] 14.4 19.2
$crt
[1] 0
$csi
[1] 0.2666667
$cxy
[1]  0.02915216 -0.46109510
$din
[1] 8.513889 1.875000
$err
[1] 0
$family
[1] ""
$fg
[1] "black"
$fig
[1] 0 1 0 1
$fin
[1] 8.513889 1.875000
$font
[1] 1
$font.axis
[1] 1
$font.lab
[1] 1
$font.main
[1] 2
$font.sub
[1] 1
$lab
[1] 5 5 7
$las
[1] 0
$lend
[1] "round"
$lheight
[1] 1
$ljoin
[1] "round"
$lmitre
[1] 10
$lty
[1] "solid"
$lwd
[1] 1
$mai
[1] 1.360000 1.093333 1.093333 0.560000
$mar
[1] 5.1 4.1 4.1 2.1
$mex
[1] 1
$mfcol
[1] 1 1
$mfg
[1] 1 1 1 1
$mfrow
[1] 1 1
$mgp
[1] 3 1 0
$mkh
[1] 0.001
$new
[1] FALSE
$oma
[1] 0 0 0 0
$omd
[1] 0 1 0 1
$omi
[1] 0 0 0 0
$pch
[1] 1
$pin
[1]  6.8605556 -0.5783333
$plt
[1] 0.1284176 0.9342251 0.7253333 0.4168889
$ps
[1] 16
$pty
[1] "m"
$smo
[1] 1
$srt
[1] 0
$tck
[1] NA
$tcl
[1] -0.5
$usr
[1] 0 1 0 1
$xaxp
[1] 0 1 5
$xaxs
[1] "r"
$xaxt
[1] "s"
$xpd
[1] FALSE
$yaxp
[1] 0 1 5
$yaxs
[1] "r"
$yaxt
[1] "s"
$ylbias
[1] 0.2

设置 par(mai=c(0,0,0,0)) 会停止错误消息,但会弄乱情节(我认为它会将绘图轴推到可查看的绘图区域之外)。 无论如何,我不明白为什么这应该是必要的 - 它应该在不需要自定义标准的情况下绘制正常。

有谁知道为什么会发生这种情况,是否有任何方法可以解决它?

如果 RStudio 中的绘图窗口太小,您将收到此错误。

请记住,可以尝试的两个选项是:

  1. 放大绘图窗口:-)
  2. 尝试使用标准图形设备进行绘图(我认为这对您来说应该是x11())。

设置par(mai=c(0,0,0,0))后,关闭并打开一个新的图形设备:

par(mai=c(0,0,0,0))    
dev.off()    
dev.new()   

最新更新