我正在尝试向自定义对图添加一个简单的图例。
这是可重现的代码(没有我的自定义配对功能):
layout(cbind(1,2),width=c(1,1))
layout.show(2)
pairs(USJudgeRatings)
为什么pairs函数会“删除”我的布局信息?
帮助中包含的警告layout
is
这些函数与在设备上排列绘图的其他机制完全不兼容:par(mfrow)、par(mfcol)
很遗憾,pairs
uses mfrow
用于安排情节。
使用来自的提示Duncan Murdoch 和 Uwe Ligges 谈 R 帮助 https://stat.ethz.ch/pipermail/r-help/2001-September/015379.html,你可以设置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"))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)