How to colourise some cell borders in R corrplot?

前端 未结 1 1920
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 15:58

I would like to keep some cells in attention by making their borders clearly distinct from anything else.

The parameter rect.col is used to colorise all bor

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-23 16:15

    My proposal where still pseudocode mark.ids. I found best to have plt and mark.ids as the options of corrplotCellBorders which creates corrplot with bordered wanted cells

    mark.ids <- {x <- c(1), y <- c(2)} # TODO pseudocode
    corrplotCellBorders(plt, mark.ids)
    cb(plt, x, y, rectArgs=list(border="red", lwd=3))
    
    # Chat of https://stackoverflow.com/q/40538304/54964 user20650
    # createBorders.r, test.createBorders. 
    cb <- function(corrPlot, ..., rectArgs = list() ){ 
    # ... pass named vector of x and y names 
    # for upper x > y, lower x < y 
      lst <- list(...) 
    
      n <- ncol(corrPlot) 
      nms <- colnames(corrPlot) 
      colnames(corrPlot) <- if(is.null(nms)) 1:ncol(corrPlot) else nms 
    
      xleft <- match(lst$x, colnames(corrPlot)) - 0.5 
      ybottom <- n - match(lst$y, colnames(corrPlot)) + 0.5 
    
      lst <- list(xleft=xleft, ybottom=ybottom, xright=xleft+1, ytop=ybottom+1) 
      do.call(rect, c(lst, rectArgs)) 
    }
    
    corrplotCellBorders <- function(plt, mark.ids) {
      x <- mark.ids$x
      y <- mark.ids$y
      cb(plt, x, y, rectArgs=list(border="red", lwd=3))
    }
    

    Open

    • How to create mark.ids such that you can call its items by mark.ids$x and mark.ids$y?
    • Integrate point order neutrality for the upper triangle here

    0 讨论(0)
提交回复
热议问题