我有两个corr矩阵,我想在1个情节中合并:
Corr Matrix 1的示例代码:
matrix_values <- c(-0.07, -0.03, 0.1, 0.11, 0.06, 0.16, 0.16, 0.13, 0.04, 0.06, 0.05, 0.04, 0.16, 0.07, 0.1, 0.08, 0.08, 0.17, 0.07, -0.13, 0.16, -0.07, 0.09, 0.07, -0.08, 0, 0.09, -0.02, 0.18, 0.09, 0.01, -0.1, -0.04, -0.12, -0.03, 0.03, 0.09, 0.09, 0.15, -0.01, 0.15, 0.09, 0.11, 0.09, 0.15, 0.19, -0.07, -0.04, 0, -0.12, NaN, -0.02, -0.11, 0.01, 0.1, -0.1, -0.1, 0.01, 0.04, 0.08, -0.02, -0.12, 0.09, -0.05, -0.07, -0.03, -0.19, -0.07, -0.16, -0.08, -0.05, -0.04, 0.03, -0.09, -0.09, -0.12, -0.07, 0.04, 0.07, 0.04, 0.02, -0.08, -0.03, -0.18, -0.02, 0.03, -0.06, 0.03, -0.07, 0.09, 0.04, -0.06, -0.1, -0.07, 0.1, 0.02, 0.06, -0.13, -0.14, -0.06, NaN, NaN, -0.07, -0.12, 0.02, -0.02, 0.01, 0.02, -0.01, -0.08, -0.03, -0.06, -0.05, -0.15, 0, -0.12, 0.13, -0.09, -0.05, 0.05, 0.08, -0.06, 0.16, 0.16, 0, 0.06, -0.05, -0.05, 0.14, -0.02, 0.12, 0.01, -0.07, -0.06, 0.07, 0.07, -0.13, 0.06, -0.05, -0.06, -0.15, -0.07, 0.11, 0.03, 0.1, 0.05, -0.12, 0.13, -0.1, 0.04, NaN, NaN, NaN, -0.03, -0.12, -0.02, 0.23, 0.13, 0.04, 0.01, 0.1, -0.01, 0.04, 0.03, -0.02, 0, -0.01, -0.08, -0.17, -0.05, 0, -0.07, -0.13, 0.1, -0.04, -0.01, 0.05, -0.03, -0.03, 0.13, -0.03, 0.01, 0.03, -0.03, 0.06, -0.01, -0.08, 0.05, 0.12, 0.09, 0.08, 0.07, -0.04, 0.09, 0.05, 0.1, 0.03, 0.05, 0.09, 0, NaN, NaN, NaN, NaN, 0.03, -0.03, 0.13, 0.14, 0.04, -0.03, 0.05, 0.14, 0.02, 0, -0.09, 0, 0, 0.01, -0.1, -0.14, 0, 0.02, 0.04, -0.07, -0.03, -0.07, -0.08, 0.1, 0.02, 0.18, 0.07, -0.16, 0.08, 0.03, -0.01, 0.03, -0.01, -0.07, 0.01, 0.1, 0.11, -0.11, 0.04, -0.08, -0.01, -0.03, -0.02, 0.09, 0.03, 0.13, NaN, NaN, NaN, NaN, NaN, -0.01, -0.05, 0.24, 0.02, 0, 0.11, 0.22, 0.22, 0.09, 0.06, 0.1, 0.09, 0.21, 0.16, 0.08, 0.08, 0.14, 0.05, 0.14, 0.15, -0.01, 0.05, 0.23, 0.13, 0.04, 0.06, 0.11, 0.05, 0.16, 0.03, 0.06, 0.01, -0.02, 0.23, -0.05, -0.09, 0.01, -0.02, 0.08, -0.07, 0.06, -0.01, -0.02, -0.03, 0.06, NaN, NaN, NaN, NaN, NaN, NaN, 0.05, -0.02, 0.08, -0.03, 0.02, -0.05, 0.13, 0.08, 0.08, 0.11, -0.04, -0.08, 0.03, 0.09, 0.1, -0.04, 0.12, 0.12, -0.06, 0.07, -0.09, 0.03, 0.03, -0.03, -0.02, 0.05, 0.04, -0.14, -0.05, 0.15, 0.06, -0.03, 0.04, -0.06, 0.21, 0.12, 0.2, -0.04, 0.05, 0.02, 0.14, 0, 0.12, 0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.13, 0, 0.12, 0.13, 0.05, 0.03, 0.09, 0.13, -0.05, 0.1, 0.14, 0.05, 0.06, 0.11, 0.03, 0.09, 0.17, 0.04, 0.15, 0.03, 0.03, -0.1, 0.07, 0.01, 0.02, 0.04, -0.08, 0.06, 0.05, 0.14, 0.07, 0.03, 0, 0.14, 0.02, -0.01, 0.02, 0.13, 0.09, -0.16, 0.1, -0.06, -0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.14, -0.05, 0.2, 0.05, -0.07, 0.1, 0.21, 0.14, -0.04, 0.01, 0.11, 0.1, 0.17, 0.21, 0.06, 0.09, 0.17, 0.17, 0.26, -0.04, 0.04, -0.01, 0.06, 0.14, -0.11, 0.05, 0.13, -0.05, 0.14, 0.06, 0.01, -0.05, 0.03, 0.04, 0.02, -0.08, -0.09, 0, -0.08, -0.21, -0.02, -0.03, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.16, -0.1, 0.03, 0.06, 0.03, 0.16, 0.07, 0.09, -0.05, 0.02, 0.02, 0.02, 0.15, 0.04, 0.11, 0.04, 0.03, 0.08, 0.1, 0.06, -0.09, -0.03, 0.25, 0.11, -0.12, -0.12, 0.07, 0.03, 0.12, 0.11, 0.07, -0.07, 0.1, 0.11, -0.08, -0.05, -0.1, 0.1, -0.04, 0.07, 0.07, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.06, -0.04, 0.19, 0.04, -0.04, 0.07, 0.09, 0.07, -0.04, 0.03, 0.06, 0.1, 0.01, 0, 0.16, -0.07, 0.12, 0.07, 0.11, 0, 0.02, 0.17, 0.19, 0.13, -0.15, -0.14, 0.26, 0.08, 0.02, 0.08, 0.17, -0.03, -0.02, 0.17, 0.03, 0.03, -0.1, 0.1, -0.02, -0.2, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.02, 0.15, -0.01, -0.02, -0.19, 0, 0.05, -0.08, -0.09, -0.15, 0.16, 0.12, 0.08, -0.03, 0.11, 0.09, 0.08, 0.06, 0.11, -0.07, 0.2, 0.05, 0.22, 0.05, -0.1, -0.07, -0.08, 0.07, 0.18, -0.06, 0.12, -0.06, -0.06, 0.09, -0.12, -0.15, -0.16, 0, -0.21, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.07, -0.1, 0.23, -0.08, 0.01, -0.02, 0.13, 0.13, -0.04, 0.14, 0.03, 0.14, 0.07, 0.15, -0.02, 0.01, 0.05, 0.03, 0, 0.15, -0.15, 0.1, 0.11, 0.17, 0, -0.06, 0.14, -0.14, 0.03, 0.16, -0.12, -0.15, -0.1, 0.17, 0.2, -0.13, -0.11, -0.11, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.02, 0, 0.13, 0.03, -0.04, 0.03, 0.06, -0.08, -0.11, -0.08, -0.09, 0.12, 0.1, -0.01, 0.04, -0.12, -0.1, 0.01, 0.09, 0.02, 0.04, -0.03, 0.04, 0.11, -0.11, -0.15, 0.07, -0.13, -0.05, 0.15, 0.02, -0.07, 0.12, 0, 0.06, -0.05, 0.09, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.25, -0.05, 0.29, -0.04, -0.06, 0.11, 0.16, 0.07, 0.05, 0.06, 0.12, 0.09, 0.22, 0.11, 0.17, 0.1, 0.19, 0.12, 0.17, 0.03, 0.03, 0.11, 0.19, 0.17, 0.02, 0.07, 0.27, -0.02, -0.05, 0.19, 0.16, 0, 0.11, 0.14, 0.04, 0.14, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.12, -0.08, 0.36, -0.08, 0.02, -0.03, -0.04, 0, -0.14, 0.02, -0.07, 0.05, 0.01, 0.03, -0.06, -0.03, 0.04, -0.05, 0.15, -0.03, -0.2, 0.03, 0.01, 0.1, 0.15, 0.21, 0.02, -0.2, -0.03, -0.01, -0.1, 0.02, 0.05, 0.1, -0.11, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.04, 0.08, 0.2, -0.06, 0.06, 0.12, 0.2, 0.12, 0.03, 0.06, 0.08, 0.12, 0.16, 0.11, 0.15, 0.18, 0.1, 0.09, 0.04, 0.11, 0.03, 0.06, 0.11, -0.05, -0.06, 0.04, 0.04, -0.06, 0.11, 0.18, 0.12, -0.06, -0.06, 0.13, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.09, 0.04, -0.05, 0.12, 0.13, 0.13, 0.13, 0.07, 0.16, 0.05, 0.07, -0.1, 0.08, -0.05, -0.01, -0.06, -0.07, 0.01, -0.07, -0.05, 0.13, -0.06, -0.01, -0.07, -0.06, -0.02, 0.11, -0.07, 0.13, -0.02, -0.03, 0.03, -0.09, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.13, -0.12, 0.07, -0.03, -0.03, -0.06, -0.1, 0.04, -0.12, 0.07, -0.04, -0.08, -0.16, -0.03, -0.11, -0.24, -0.08, -0.04, -0.04, -0.13, -0.19, -0.01, -0.01, 0, -0.08, -0.03, -0.06, -0.15, -0.11, -0.05, -0.05, -0.02, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.18, -0.13, 0.03, 0.09, -0.03, -0.09, 0.14, 0.02, 0, 0.05, -0.11, -0.08, 0.04, -0.04, -0.03, -0.16, 0.01, -0.03, 0.11, -0.11, -0.1, 0.02, 0.01, 0.06, -0.05, -0.01, 0.15, -0.05, 0.08, 0.01, -0.07, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.04, -0.13, 0.13, 0.15, 0.23, 0.23, 0.13, 0.1, 0.01, 0.04, 0.04, 0.08, 0.09, 0.08, 0.03, 0.03, 0.13, 0.14, 0.04, 0.01, 0.09, -0.03, 0.12, 0.01, -0.06, -0.11, 0.09, -0.13, 0.02, 0.17, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.07, 0.11, 0.09, -0.08, 0.01, -0.04, 0.05, 0.16, -0.03, 0.08, 0.02, 0.05, -0.11, 0.1, 0.01, -0.07, 0.05, 0, 0.05, 0.09, -0.22, -0.09, 0.05, -0.05, -0.05, -0.04, -0.02, -0.11, -0.09, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.24, 0.07, 0.05, 0.07, 0.11, -0.11, -0.08, -0.16, -0.13, -0.07, -0.03, 0.01, -0.06, -0.07, -0.01, -0.07, 0.04, 0.04, -0.1, -0.04, 0.06, 0.04, 0.16, 0.08, -0.05, -0.09, 0.13, 0.14, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.04, 0.01, 0, 0.05, 0, 0.07, -0.02, -0.06, -0.07, -0.12, -0.02, 0.08, -0.01, -0.07, -0.14, -0.11, -0.14, -0.04, 0.01, -0.15, 0.15, -0.15, -0.02, 0.02, -0.14, -0.1, -0.06, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.14, 0.08, 0.34, 0.02, 0.16, 0.04, 0.12, 0.21, 0.03, 0.07, 0.18, 0.02, 0.02, 0.03, 0.04, 0, 0.02, 0.05, 0.1, 0.01, -0.05, -0.07, 0.08, -0.08, -0.02, -0.01, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.06, -0.12, -0.02, 0.06, 0.08, -0.11, -0.05, -0.07, -0.06, -0.08, -0.12, 0, -0.03, -0.08, -0.11, -0.17, -0.02, -0.05, 0.01, -0.15, -0.21, -0.03, -0.04, 0.03, -0.03, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.02, -0.07, -0.03, 0.02, -0.08, -0.1, -0.08, -0.01, -0.07, -0.02, -0.15, 0.04, -0.07, -0.04, -0.22, -0.09, -0.1, -0.02, -0.14, -0.15, -0.22, -0.06, -0.07, 0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.09, -0.04, 0.02, 0.14, 0.15, 0.13, 0.02, 0.07, -0.01, 0.08, 0.1, -0.13, 0.1, -0.02, 0.02, 0.01, 0.05, 0.07, -0.07, 0.01, 0.04, -0.13, 0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.06, 0.14, 0.07, 0.15, 0.1, 0.09, 0.14, 0.09, 0.03, 0.04, 0.13, 0.02, 0.13, -0.02, 0.21, -0.03, 0.03, 0.12, -0.06, 0.08, 0.13, 0.01, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.04, -0.09, 0.08, 0.01, 0.04, 0.01, 0, 0.06, 0.04, 0.03, 0.09, -0.12, -0.06, -0.01, -0.09, -0.11, -0.07, -0.04, -0.05, -0.1, 0.01, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.12, 0.09, -0.05, 0, 0.08, 0.02, -0.08, -0.15, -0.14, -0.16, 0.03, 0, -0.03, -0.11, 0.04, -0.09, -0.17, -0.09, -0.05, -0.05, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.07, -0.07, 0.09, -0.07, 0.07, 0.05, 0.06, 0.23, 0, 0.11, -0.01, 0.03, 0.04, 0.07, 0.04, -0.01, 0.01, 0.04, -0.03, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.03, -0.15, -0.01, 0.14, 0.19, 0.03, -0.1, -0.03, -0.12, 0.04, -0.14, 0.05, -0.15, -0.09, 0.03, -0.16, 0.05, 0.12, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.08, -0.05, 0.09, -0.08, 0.09, 0.05, 0.08, 0.05, -0.08, 0.03, -0.04, 0.06, -0.15, 0.06, 0.07, 0.09, 0.01, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.02, 0.04, 0.1, -0.16, 0.05, 0, 0.06, 0.06, -0.05, -0.01, -0.13, 0.11, -0.1, 0.03, 0.08, -0.09, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.02, -0.18, -0.11, 0.02, 0.06, 0.01, -0.18, -0.03, -0.19, -0.01, -0.23, 0.02, -0.11, -0.06, 0.03, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.04, -0.07, 0.07, 0.09, 0.08, 0.1, 0.06, 0.12, -0.06, -0.04, 0.12, 0.14, -0.03, 0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, -0.01, 0.23, -0.09, 0.1, -0.07, -0.01, 0.13, -0.05, 0.07, -0.11, 0.01, -0.17, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.1, 0.04, 0.05, -0.06, 0.17, 0, -0.03, 0.01, -0.14, 0.08, -0.05, 0.16, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.03, 0.04, -0.1, 0.1, 0.17, 0.12, 0.19, 0.1, 0.24, 0.15, 0.03, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0.13, -0.11, -0.02, 0.14, 0.01, -0.07, -0.07, -0.08, -0.1, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.1, 0.07, 0.19, -0.06, 0.12, -0.09, 0.13, 0.2, -0.16, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0, 0.06, 0.04, -0.19, 0.05, -0.08, 0, 0.04, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.03, 0.1, 0.17, -0.03, 0.05, 0.01, 0.25, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.11, 0.15, 0.13, -0.11, 0.16, 0.05, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.05, 0.06, 0.1, 0.06, 0.18, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.09, 0.02, 0.3, 0.11, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.02, 0.06, 0.21, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, 0.01, -0.01, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, -0.21, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN)
cor_matrix1 <- matrix(matrix_values, ncol = 51, nrow = 51)
dat <- melt(cor_matrix1[-52, ])
r <- ggplot(data = dat, aes(x = Var1, y = Var2)) +
geom_tile(aes(fill = value), color = "white") +
scale_fill_gradientn(values=c(1, .6, .5, .4, 0), colours=c("#770000", "red", "#ff8000", "#ffff00", "#ffffe5"))+
theme( axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_blank())
Corr Matrix 2的示例代码:
cor_matrix2 <- matrix(matrix_values, ncol = 51, nrow = 51)
dat <- melt(cor_matrix2[-52, ])
p <- ggplot(data = dat, aes(x = Var1, y = Var2)) +
geom_tile(aes(fill = value), color = "white") +
scale_fill_gradientn(values=c(1, .6, .5, .4, 0), colours=c("#00007f", "#1212b2", "cyan", "#b4b4cc", "white"))
答案 0 :(得分:2)
据我所知,ggplot不允许你为同一个情节使用多个色阶。它还使您的图形难以解释。但是,你可以通过形状变得聪明:
处理数据的一些预处理,我确信在生成数据集时可以避免一些:
cor_matrix1 <- matrix(matrix_values, ncol = 51, nrow = 51)
dat1 <- melt(cor_matrix1[-52, ])
cor_matrix2 <- matrix(matrix_values, ncol = 51, nrow = 51)
dat2 <- melt(cor_matrix2[-52, ])
dat2$Var1 <- 52 - dat2$Var1
dat2$Var2 <- 52 - dat2$Var2
dat1$Class <- "A"
dat2$Class <- "B"
dat <- rbind(dat1,dat2)
dat <- dat[!is.nan(dat$value),]
不要使用geom_tile
,请尝试geom_point
。这将使您可以灵活地使用形状。 (即,分割数据的附加维度):
ggplot(data = dat, aes(x = Var1, y = Var2)) +
geom_point(size = 4, aes(color = value, pch = Class)) +
scale_color_gradientn(values=c(1, .6, .5, .4, 0), colours=c("#00007f", "#1212b2", "cyan", "#b4b4cc", "white")) +
geom_abline(slope = -1,intercept = 52 , size = 2) +
geom_rect(xmin = 30, xmax = 31, ymin = 30, ymax = 31, color = "red", fill = NA) +
theme( axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.background = element_blank())
给出了:
这里发生了一些事情:
pch
的{{1}}参数为每个人口设置不同的形状geom_point
为你提供了图表中心的黑线(你也可以用点数来做,但我认为这更清楚geom_abline
参数创建红色矩形。根据需要调整分钟/最大值,并根据需要加入。另外,请注意此处的负相关将变为白色(根据您定义的色标)。我会发现这种误导。