How to colourise some cell borders in R corrplot?

廉价感情. 提交于 2019-12-02 04:10:38
Léo Léopold Hertz 준영

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!