定制ggpairs以使相关矩阵更具可读性

下面的代码创建了一个不太可读的关联矩阵可视化:

1)文字太大,单元格内的数字不可读
2)x轴和y轴上的刻度不提供信息,因为它们拥挤太多

你能否告诉我如何处理这些问题:

代码如下:

library(GGally)
library(ggplot2)
library(data.table)
library(ROSE)
library(dplyr)

#===================================================================================================================
# LOAD THE DATA
#===================================================================================================================

data(hacide)

train <- hacide.train

#=============================================================================================================
# FEATURE EXTRACTION
#=================================================================================================================

setDT(train)

train <- train %>% mutate(

  x11 = ifelse(x1 < -1.4, 1, 0),
  x12 = ifelse(((x1 >= -1.4) & (x1 < -0.74)), 1, 0),
  x13 = ifelse(((x1 >= -0.74) & (x1 < 1)), 1, 0),
  x14 = ifelse(x2 >= 1, 1, 0),
  x21 = ifelse(x2 < -1.4, 1, 0),
  x22 = ifelse(((x2 >= -1.4) & (x2 < -1)), 1, 0),
  x23 = ifelse(((x2 >= -1) & (x2 < 0.5)), 1, 0),
  x24 = ifelse(x2 >= 0.5, 1, 0),
  x3 = x1 ^ 2 - x2
)

#=========================================================================================================
# EXAMINE CORRELATIONS
#=========================================================================================================

ggpairs(train , 
        lower = list(continuous = wrap("points", color = "red", alpha = 0.5), 
                     combo = wrap("box", color = "orange", alpha = 0.3), 
                     discrete = wrap("facetbar", color = "yellow", alpha = 0.3) ), 
        diag = list(continuous = wrap("densityDiag",  color = "blue", alpha = 0.5) ))

情节如下:

在这里输入图像描述

链接地址: http://www.djcxy.com/p/30865.html

上一篇: Customizing ggpairs to make the correlation matrix more readable

下一篇: "Incorrect Plot" label in ggpairs