如何仅显示ggpairs中的下部三角形?

Ric*_*ord 5 r ggplot2

我使用ggpairs做一个对剧情,但我只想要显示的下三角。我可以将对角线和上三角设为空白,但不能使它们离开,从而留下了我不希望的空白行和空白列。

有什么建议么?

library("GGally")
ggpairs(iris[, 1:4], 
        lower  = list(continuous = "points"),
        upper  = list(continuous = "blank"),
        diag  = list(continuous = "blankDiag")
        )
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Ric*_*ord 6

的ggpairs对象可以被编辑。所述物体的体积是list曲线的。可以从此列表中删除不需要的图,并ggpairs修改对象的其他元素以使其匹配。

这里是会做这样的功能

gpairs_lower <- function(g){
  g$plots <- g$plots[-(1:g$nrow)]
  g$yAxisLabels <- g$yAxisLabels[-1]
  g$nrow <- g$nrow -1

  g$plots <- g$plots[-(seq(g$ncol, length(g$plots), by = g$ncol))]
  g$xAxisLabels <- g$xAxisLabels[-g$ncol]
  g$ncol <- g$ncol - 1

  g
}

library("GGally")
g <- ggpairs(iris[, 1:4], 
             lower  = list(continuous = "points"),
             upper  = list(continuous = "blank"),
             diag  = list(continuous = "blankDiag")
     )

gpairs_lower(g)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明