Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

Use panel.cor function for correlation plots? #1

Open
iantaylor-NOAA opened this issue Feb 7, 2015 · 1 comment
Open

Use panel.cor function for correlation plots? #1

iantaylor-NOAA opened this issue Feb 7, 2015 · 1 comment

Comments

@iantaylor-NOAA
Copy link
Contributor

Nathan says "I've found it useful to use the panel.cor function to numerically report the parameter correlations in the upper right triangle of the plot." Seems like an easy change to make for 2016.

@allanhicks
Copy link
Contributor

Nathan says this is the code:

put (absolute) correlations on the upper panels,
with size proportional to the correlations.
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits = digits)[1]
txt <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
pairs(USJudgeRatings, lower.panel = panel.smooth, upper.panel = panel.cor)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants