我正在使用 R 包ellipse
来可视化相关性。我的问题是如何将 6 个不同的相关图放在一个图中?我试过
use
par(mfrow=c(3,2), mar=c(3.1, 4.1, 2.1, 5.1))
,它有效,但我只能看到 6 小组数字。使用
grid.arrange
它给我错误信息Error in arrangeGrob(..., as.table = as.table, clip = clip, main = main, : input must be grobs!
有没有办法解决这个问题?谢谢!
这是我的示例代码
colors <- c("#A50F15","#DE2D26","#FB6A4A","#FCAE91","#FEE5D9","white",
"#EFF3FF","#BDD7E7","#6BAED6","#3182BD","#08519C")
tiff(file = "Fig7.tiff", width = 10000, height = 8000, units = "px", res = 800, compression = "lzw") #
par(mfrow=c(3,2))
for (i in 1:6){
plotcorr(cor(replicate(10, rnorm(10))), col=colors[5*cor(replicate(10, rnorm(10))) + 6], numbers = TRUE)
plotcorr(cor(replicate(10, rnorm(10))), col=colors[5*cor(replicate(10, rnorm(10))) + 6], numbers = TRUE)
}
dev.off()
我通过修改边距弄清楚了。再次感谢!
plotcorr(eval(parse(text=cor_name_app)), col=colors[5*eval(parse(text=cor_name_app)) + 6], mar = 0.1 + c(0.2,0.2,0.4,0.2))