如何在R中结合布局使用对功能?

Cha*_*apo 5 layout r

我正在尝试将一个简单的图例添加到自定义对图中.

这是可重现的代码(没有我的自定义对功能):

layout(cbind(1,2),width=c(1,1))
layout.show(2)
pairs(USJudgeRatings)
Run Code Online (Sandbox Code Playgroud)

为什么对功能"擦除"我的布局信息?

mne*_*nel 12

帮助中包含的警告layout

这些功能与在设备上排列图的其他机制完全不兼容:par(mfrow),par(mfcol)

不幸的是,pairs使用mfrow安排的地块.

使用Duncan Murdoch和Uwe Ligges提供的R帮助提示,您可以设置oma一个合理的值,为您提供侧面传奇的空间,例如

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
      pch = 21, bg = c("red", "green3", "blue")[iris$Species],
      oma=c(4,4,6,12))
# allow plotting of the legend outside the figure region 
# (ie within the space left by making the margins big)
par(xpd=TRUE)
legend(0.85, 0.7, as.vector(unique(iris$Species)),  
       fill=c("red", "green3", "blue"))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述