R 将 corrplot 作为对象返回 [英] R return corrplot as object

查看:23
本文介绍了R 将 corrplot 作为对象返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

corrplot 绘制相关矩阵,但不返回图形对象 (grob)

corrplot plots a correlation matrix, but it does not return a graphical object (grob)

我想在一个页面上绘制多个相关矩阵.对于普通图,我将使用 gridExtra 包中的 grid.arrange.但是,由于 corrplot 仅打印而不返回对象,因此我不知道如何执行此操作.

I would like to plot several correlation matrices on a single page. For normal plots, I would use grid.arrange from the gridExtra package. However since corrplot only prints and does not return an object, I can't see how to do this.

corrplot 是否有解决方法或更好的替代方法?

Is there a workaround or a better alternative to corrplot ?

推荐答案

There's old stand par(mfrow=c(x, y)) 其中 x 是您希望绘制的行数和 y 列数.然后在您调用情节时横向然后向下张贴.

There's the old standby par(mfrow=c(x, y)) where x is the number of rows you wish to plot and y the numberof columns. It then posts across and then down as you call the plots.

par(mfrow = c(2, 2))
corrplot(cor(mat1))
corrplot(cor(mat2))
corrplot(cor(mat3))
corrplot(cor(mat4))

par(mfrow = c(1, 1)) #To clear layout

将绘制为

Mat1 | Mat2
-----------
Mat3 | Mat4

这篇关于R 将 corrplot 作为对象返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆