[[在此处输入图片描述](https://i.stack.imgur.com/caLkX.png)][1]
我正在尝试修改代码。 在上面板中,我想添加相关系数的数字和圆圈值。然而,数字值从圆圈回来了。
panel.cor <- function (w, z, digits = 2, prefix = "", cex.cor, ...) {
correlation <- cor(w, z, method = "pearson")
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
txt <- format(c(correlation, 0.123456789), digits = digits)[1]
txt <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 2 # or 0.8/strwidth(txt)
text(0.8, 0.25, txt, cex = 1.5, font = 2, z = Inf) # was cex.cor * abs(r))
## because the func needs [0,1] and cor gives [-1,1], we need to
## shift and scale it
col <- rgb( myColorRampFunc( (1+correlation)/2 )/255 )
## square it to avoid visual bias due to "area vs diameter"
radius <- sqrt(abs(correlation))
radians <- seq(0, 2*pi, len=50) # 50 is arbitrary
x <- radius * cos(radians)
y <- radius * sin(radians)
## make them full loops
x <- c(x, tail(x,n=1))
y <- c(y, tail(y,n=1))
## I trick the "don't create a new plot" thing by following the
## advice here: http://www.r-bloggers.com/multiple-y-axis-in-a-r-plot/
## This allows
par(new=TRUE)
plot(0, type='n', xlim=c(-1,1), ylim=c(-1,1), axes=FALSE, asp=1)
polygon(x, y, border=col, col=col)
}
我想把数值放在前面。 此外,我想删除 diag.panel 的框架并将 diag.panel 的颜色更改为红色。