问题描述
corrplot
绘制一个相关矩阵,但不返回图形对象(毛刺)
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
?
推荐答案
有一个旧的备用数据库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返回为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!